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

DecimalFormat / rounding / HALF_UP

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Not an Issue
    • Affects Version/s: 8u25
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      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

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

                Dates

                • Created:
                  Updated:
                  Resolved: