Skip to content

RoundUp() and RoundDown() with Negative Numbers #375

@langurs

Description

@langurs

The RoundUp() and RoundDown() functions treat negative numbers the opposite of what I would expect. For example, if you're rounding "up," I would expect the number -1.45 could become -1.4, but not -1.5.

The "Math is Fun" and Wikipedia websites seems to have a good description of the variations (https://www.mathsisfun.com/numbers/rounding-methods.html and https://en.wikipedia.org/wiki/Rounding).

Also, I saw no tests for negative numbers in TestDecimal_RoundAndStringFixed(), so I tried adding some, but got some strange results. You might want to try it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions