mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-06 08:51:14 -03:00
Convert \\subsection sections into rst format
This commit is contained in:
@@ -7,7 +7,8 @@ Synopsis
|
||||
math [-sN | --scale=N] [--] EXPRESSION
|
||||
|
||||
|
||||
\subsection math-description Description
|
||||
Description
|
||||
------------
|
||||
|
||||
`math` is used to perform mathematical calculations. It supports all the usual operations such as addition, subtraction, etc. As well as functions like `abs()`, `sqrt()` and `log2()`.
|
||||
|
||||
@@ -21,17 +22,20 @@ The following options are available:
|
||||
|
||||
- `-sN` or `--scale=N` sets the scale of the result. `N` must be an integer. A scale of zero causes results to be rounded down to the nearest integer. So `3/2` returns `1` rather than `2` which `1.5` would normally round to. This is for compatibility with `bc` which was the basis for this command prior to fish 3.0.0. Scale values greater than zero causes the result to be rounded using the usual rules to the specified number of decimal places.
|
||||
|
||||
\subsection return-values Return Values
|
||||
Return Values
|
||||
------------
|
||||
|
||||
If the expression is successfully evaluated and doesn't over/underflow or return NaN the return `status` is zero (success) else one.
|
||||
|
||||
\subsection math-syntax Syntax
|
||||
Syntax
|
||||
------------
|
||||
|
||||
`math` knows some operators, constants, functions and can (obviously) read numbers.
|
||||
|
||||
For numbers, `.` is always the radix character regardless of locale - `2.5`, not `2,5`. Scientific notation (`10e5`) is also available.
|
||||
|
||||
\subsection math-operators Operators
|
||||
Operators
|
||||
------------
|
||||
|
||||
`math` knows the following operators:
|
||||
|
||||
@@ -47,7 +51,8 @@ For numbers, `.` is always the radix character regardless of locale - `2.5`, not
|
||||
|
||||
They are all used in an infix manner - `5 + 2`, not `+ 5 2`.
|
||||
|
||||
\subsection math-constants Constants
|
||||
Constants
|
||||
------------
|
||||
|
||||
`math` knows the following constants:
|
||||
|
||||
@@ -56,7 +61,8 @@ They are all used in an infix manner - `5 + 2`, not `+ 5 2`.
|
||||
|
||||
Use them without a leading `$` - `pi - 3` should be about 0.
|
||||
|
||||
\subsection math-functions Functions
|
||||
Functions
|
||||
------------
|
||||
|
||||
`math` supports the following functions:
|
||||
|
||||
@@ -85,7 +91,8 @@ Use them without a leading `$` - `pi - 3` should be about 0.
|
||||
|
||||
All of the trigonometric functions use radians.
|
||||
|
||||
\subsection math-example Examples
|
||||
Examples
|
||||
------------
|
||||
|
||||
`math 1+1` outputs 2.
|
||||
|
||||
@@ -99,7 +106,8 @@ All of the trigonometric functions use radians.
|
||||
|
||||
`math "sin(pi)"` outputs `0`.
|
||||
|
||||
\subsection math-notes Compatibility notes
|
||||
Compatibility notes
|
||||
------------
|
||||
|
||||
Fish 1.x and 2.x releases relied on the `bc` command for handling `math` expressions. Starting with fish 3.0.0 fish uses the tinyexpr library and evaluates the expression without the involvement of any external commands.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user