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

Regression in NumberFormat rounding from 1.7 to 1.8. Rounding no longer works.

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Not an Issue
    • Affects Version/s: 8
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0-ea"
      Java(TM) SE Runtime Environment (build 1.8.0-ea-b118)
      Java HotSpot(TM) 64-Bit Server VM (build 25.0-b60, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Linux Studio-XPS-9100 3.2.0-31-generic #50-Ubuntu SMP Fri Sep 7 16:16:45 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      A NumberFormat object with the RoundingMode set to HALF_EVEN rounds correctly in jdk 1.7, but no longer rounds in jdk 1.8.
      Code for a test case is given in the Steps to Reproduce


      REGRESSION. Last worked in version 7u40

      ADDITIONAL REGRESSION INFORMATION:
      Broken version:
      java version "1.8.0-ea"
      Java(TM) SE Runtime Environment (build 1.8.0-ea-b118)
      Java HotSpot(TM) 64-Bit Server VM (build 25.0-b60, mixed mode)


      Previous, working version:
      java version "1.7.0_40"
      Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
      Java HotSpot(TM) 64-Bit Server VM (build 24.0-b56, mixed mode)


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      The following test will print "55.6%" in jdk 1.7 (which is correct) but will print "55.5%" in jdk 1.8 (incorrect).

      import java.text.NumberFormat;
      import java.math.RoundingMode;
      public class NumberFormatTest {
          public static void main(String[] args) {
              NumberFormat percent = NumberFormat.getPercentInstance();
              percent.setMinimumFractionDigits(1);
              percent.setMaximumFractionDigits(1);
              percent.setRoundingMode(RoundingMode.HALF_EVEN);
              System.out.println(0.5555);
              System.out.println(percent.format(0.5555));
          }
      }

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      print "55.6%"
      ACTUAL -
      prints "55.5%"

      REPRODUCIBILITY :
      This bug can be reproduced always.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                olagneau Olivier Lagneau (Inactive)
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: