mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-04-22 10:11:13 -03:00
Change how math rounds integer results
We need our `math` builtin to behave like `bc` with respect to rounding floating point values to integer to avoid breaking to many existing uses. So when scale is zero round down to the nearest integer. Another change for #3157.
This commit is contained in:
@@ -15,7 +15,7 @@ The `math` command can evaluate multiple expressions separated by commas. The re
|
||||
|
||||
The following options are available:
|
||||
|
||||
- `-sN` or `--scale=N` sets the scale of the result. `N` must be an integer and defaults to zero (rounded to the nearest integer).
|
||||
- `-sN` or `--scale=N` sets the scale of the result. `N` must be an integer and defaults to zero. 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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user