Skip to content

Java: Add support for additional rounding rules in arithmetic operations and other functions #115

Description

@A1trdX

Currently, the arithmetic operations (e.g. multiply(), divide(), etc.) and other functions in Decimal64Utils (from dfp) and Decimal64MathUtils (from dfp-math) apparently support only one rounding rule: "Round to nearest, ties to even."

However, IEEE-754 standard also defines:

  • Rounding to nearest, ties away from zero
  • Round toward positive infinity
  • Round toward negative infinity
  • Round toward zero (truncation)

The last three are implemented on Intel hardware.

Could you add support for the remaining rounding rules of the IEEE-754 standard? Or at least for the last three?

This is how I see it in the API. For each method that requires rounding, add a similar one with the ability to specify a rounding rule, for example: long divide(long x, long y, RoundingMode mode).

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