Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8066414

DecimalFormat multiplier attribute implementation for double values close to tie causes rounding errors

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • tbd
    • 8, 9
    • core-libs
    • generic
    • generic

      DecimalFormat.format(double/float, ...) 'multiplier' attribute is implemented by doing multiply and divide operations like :
      - passedValue * multiplier
      - passedValue / multiplier

      That introduces floating-point errors on the value to be formatted.

      This is not impacting as long as the initial value is far enough from the tie when considering rounding mode.

      When close to tie the error impact the result and brings rounding errors, like rounding down when it should be rounded up.

      multiplier attribute should be implemented differently avoid such rounding errors.

            nishjain Nishit Jain
            olagneau Olivier Lagneau (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: