mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-28 05:43:11 +00:00
docs: Document the math functions better
This commit is contained in:
parent
1a03c23b58
commit
018f1f7e20
1 changed files with 20 additions and 18 deletions
|
@ -73,31 +73,31 @@ Functions
|
||||||
|
|
||||||
``math`` supports the following functions:
|
``math`` supports the following functions:
|
||||||
|
|
||||||
- ``abs``
|
- ``abs`` - the absolute value, with positive sign
|
||||||
- ``acos``
|
- ``acos`` - arc cosine
|
||||||
- ``asin``
|
- ``asin`` - arc sine
|
||||||
- ``atan``
|
- ``atan`` - arc tangent
|
||||||
- ``atan2``
|
- ``atan2`` - arc tangent of two variables
|
||||||
- ``bitand``, ``bitor`` and ``bitxor`` to perform bitwise operations. These will throw away any non-integer parts and interpret the rest as an int.
|
- ``bitand``, ``bitor`` and ``bitxor`` to perform bitwise operations. These will throw away any non-integer parts and interpret the rest as an int.
|
||||||
- ``ceil``
|
- ``ceil`` - round number up to nearest integer
|
||||||
- ``cos``
|
- ``cos`` - the cosine
|
||||||
- ``cosh``
|
- ``cosh`` - hyperbolic cosine
|
||||||
- ``exp`` - the base-e exponential function
|
- ``exp`` - the base-e exponential function
|
||||||
- ``fac`` - factorial
|
- ``fac`` - factorial - also known as ``x!`` (``x * (x - 1) * (x - 2) * ... * 1``)
|
||||||
- ``floor``
|
- ``floor`` - round number down to nearest integer
|
||||||
- ``ln`` - the base-e logarithm
|
- ``ln`` - the base-e logarithm
|
||||||
- ``log`` or ``log10`` - the base-10 logarithm
|
- ``log`` or ``log10`` - the base-10 logarithm
|
||||||
- ``ncr``
|
- ``ncr`` - "from n choose r" combination function - how many subsets of size r can be taken from n (order doesn't matter)
|
||||||
- ``npr``
|
- ``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``)
|
- ``pow(x,y)`` returns x to the y (and can be written as ``x ^ y``)
|
||||||
- ``round`` - rounds to the nearest integer, away from 0
|
- ``round`` - rounds to the nearest integer, away from 0
|
||||||
- ``sin``
|
- ``sin`` - the sine function
|
||||||
- ``sinh``
|
- ``sinh`` - the hyperbolic sine
|
||||||
- ``sqrt``
|
- ``sqrt`` - the square root - (can also be written as ``x ^ 0.5``)
|
||||||
- ``tan``
|
- ``tan`` - the tangent
|
||||||
- ``tanh``
|
- ``tanh`` - the hyperbolic tangent
|
||||||
|
|
||||||
All of the trigonometric functions use radians.
|
All of the trigonometric functions use radians (the pi-based scale, not 360°).
|
||||||
|
|
||||||
Examples
|
Examples
|
||||||
--------
|
--------
|
||||||
|
@ -124,6 +124,8 @@ Examples
|
||||||
|
|
||||||
``math --base=hex 192`` prints ``0xc0``.
|
``math --base=hex 192`` prints ``0xc0``.
|
||||||
|
|
||||||
|
``math 'ncr(49,6)'`` prints 13983816 - that's the number of possible picks in 6-from-49 lotto.
|
||||||
|
|
||||||
Compatibility notes
|
Compatibility notes
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue