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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions