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

DecimalFormat / rounding / HALF_UP

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • P3
    • Resolution: Not an Issue
    • 8u25
    • None
    • core-libs
    • x86_64
    • windows_7

    Description

      FULL PRODUCT VERSION :
      java version "1.8.0_25"
      Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
      Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      Problem with rounding up:

      DecimalFormat l_format = new DecimalFormat();

      l_format.setRoundingMode(RoundingMode.HALF_UP);
      l_format.setMaximumFractionDigits(2);
      l_format.getDecimalFormatSymbols().setDecimalSeparator('.');

      System.out.println(l_format.format(13.135d));

      With 2 fraction digits I think the output must be 13.14, but it is 13.13 even after the fix for Bug-ID: 8039915 (applied in the boot class path with the jdk8-dev sources).

      REGRESSION. Last worked in version 7u72

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Just execute the code written in the description.


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      DecimalFormat l_format = new DecimalFormat();

      l_format.setRoundingMode(RoundingMode.HALF_UP);
      l_format.setMaximumFractionDigits(2);
      l_format.getDecimalFormatSymbols().setDecimalSeparator('.');

      assertEquals(13.14d, l_format.format(13.135d));
      ---------- END SOURCE ----------

      Attachments

        Issue Links

          Activity

            People

              olagneau Olivier Lagneau (Inactive)
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: