8000 math: Add scale argument to "round" · Issue #9117 · fish-shell/fish-shell · GitHub
[go: up one dir, main page]

Skip to content

math: Add scale argument to "round" #9117

@kseistrup

Description

@kseistrup

The fish math functions seems to get it wrong sometimes, when doing integer math:

> math --scale=0 "22 / 5"         # this is all fine
4
> math --scale=0 "22 / 5 - 5"     # this ought to give -1
-0
> math --scale=0 "-5 + (22 / 5)"  # parentheses or reverting expression doesn't help
-0

This has been a problem for all fish3 releases, as far as I can tell, but I always thought it was an error in my scripts.

> fish --version
fish, version 3.5.1
> uname -a
Linux home 5.18.16-arch1-1 #1 SMP PREEMPT_DYNAMIC Wed, 03 Aug 2022 11:25:04 +0000 x86_64 GNU/Linux