mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 06:41:42 +08:00
math: Add log2
This was already in the documentation as an example, now it is actually working. Fixes #7734
This commit is contained in:
parent
dc417f58ae
commit
cbd8f5f63e
|
@ -87,6 +87,7 @@ Functions
|
|||
- ``floor`` - round number down to nearest integer
|
||||
- ``ln`` - the base-e logarithm
|
||||
- ``log`` or ``log10`` - the base-10 logarithm
|
||||
- ``log2`` - the base-2 logarithm
|
||||
- ``ncr`` - "from n choose r" combination function - how many subsets of size r can be taken from n (order doesn't matter)
|
||||
- ``npr`` - the number of subsets of size r that can be taken from a set of n elements (including different order)
|
||||
- ``pow(x,y)`` returns x to the y (and can be written as ``x ^ y``)
|
||||
|
|
|
@ -202,6 +202,7 @@ static const te_builtin functions[] = {
|
|||
{L"ln", reinterpret_cast<const void *>(static_cast<te_fun1>(log)), TE_FUNCTION1},
|
||||
{L"log", reinterpret_cast<const void *>(static_cast<te_fun1>(log10)), TE_FUNCTION1},
|
||||
{L"log10", reinterpret_cast<const void *>(static_cast<te_fun1>(log10)), TE_FUNCTION1},
|
||||
{L"log2", reinterpret_cast<const void *>(static_cast<te_fun1>(log2)), TE_FUNCTION1},
|
||||
{L"ncr", reinterpret_cast<const void *>(static_cast<te_fun2>(ncr)), TE_FUNCTION2},
|
||||
{L"npr", reinterpret_cast<const void *>(static_cast<te_fun2>(npr)), TE_FUNCTION2},
|
||||
{L"pi", reinterpret_cast<const void *>(static_cast<te_fun0>(pi)), TE_FUNCTION0},
|
||||
|
|
|
@ -186,3 +186,6 @@ math --base notabase
|
|||
# CHECKERR: math: 'notabase' is not a valid base value
|
||||
echo $status
|
||||
# CHECK: 2
|
||||
|
||||
math 'log2(8)'
|
||||
# CHECK: 3
|
||||
|
|
Loading…
Reference in New Issue
Block a user