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

RoundingMode.HALF_UP does not round up the values as expected.

    Details

    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      A DESCRIPTION OF THE PROBLEM :
      RoundingMode.HALF_UP is not working correctly.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile the attached code

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      1.985 : 1.98
      23.985 : 23.98
      Hello World
      ACTUAL -
      1.985 : 1.99
      23.985 : 23.98
      Hello World

      ---------- BEGIN SOURCE ----------
      import java.text.DecimalFormat;
      import java.math.RoundingMode;
      public class Main
      {
      public static void main(String[] args) {
      DecimalFormat df = new DecimalFormat("##.00");
                  df.setRoundingMode(RoundingMode.HALF_UP);
                  System.out.println("1.985 : " + df.format(1.985));
                  System.out.println("23.985 : " + df.format(23.985));
      System.out.println("Hello World");
      }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: