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

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

XMLWordPrintable

    • generic
    • generic

      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 ----------

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

              Created:
              Updated:
              Resolved: