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

Wrong DecimalFormat.format() HALF_UP rounding when last digit is 5

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      A DESCRIPTION OF THE PROBLEM :
      Using DecimalFormat with RoundingMode.HALF_UP doesn't round correct when last digit is 5 and have decimal place.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      DecimalFormat decimalFormat = new DecimalFormat("0.0");
      decimalFormat.setRoundingMode(RoundingMode.HALF_UP);
      decimalFormat.format(0.15);


      ---------- BEGIN SOURCE ----------
      DecimalFormat decimalFormat = new DecimalFormat("0.0");
      decimalFormat.setRoundingMode(RoundingMode.HALF_UP);
      decimalFormat.format(0.15);
      ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              tongwan Andrew Wang
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: