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

Error in decimal multiplication

XMLWordPrintable

    • generic
    • generic

      FULL PRODUCT VERSION :


      ADDITIONAL OS VERSION INFORMATION :
      Linux ubuntu 14.4

      A DESCRIPTION OF THE PROBLEM :
      I have a problem, next code:

      DecimalFormat decimalFormat = new DecimalFormat(".##");
      decimalFormat.setRoundingMode(RoundingMode.DOWN);

      double performance = 0.578954121
      String sperf = decimalFormat.format(performance);
      performance = Double.parseDouble(sperf); // .57
      performance *= 100; //should be 57, it show 56.99999999999999

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      DecimalFormat decimalFormat = new DecimalFormat(".##");
      decimalFormat.setRoundingMode(RoundingMode.DOWN);

      double performance = 0.578954121
      String sperf = decimalFormat.format(performance);
      performance = Double.parseDouble(sperf); // .57
      performance *= 100; //should be 57, it show 56.99999999999999

      ACTUAL -
      56.99999999999999

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      No errors

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      DecimalFormat decimalFormat = new DecimalFormat(".##");
      decimalFormat.setRoundingMode(RoundingMode.DOWN);

      double performance = 0.578954121
      String sperf = decimalFormat.format(performance);
      performance = Double.parseDouble(sperf); // .57
      performance *= 100; //should be 57, it show 56.99999999999999
      ---------- END SOURCE ----------

            psonal Pallavi Sonal (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: