-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
22.0.2
-
x86_64
-
linux_ubuntu
A DESCRIPTION OF THE PROBLEM :
RoundingMode.HALF_UP gives different results with NumberFormat
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the provided code. You will see the following output:
0.675 -> 0.68
12345.675 -> 12,345.67
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
0.675 -> 0.68
12345.675 -> 12,345.68
---------- BEGIN SOURCE ----------
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
numberFormat.setMaximumFractionDigits(2);
numberFormat.setMinimumFractionDigits(2);
numberFormat.setRoundingMode(RoundingMode.HALF_UP);
System.out.println("0.675 -> " + numberFormat.format(0.675));
System.out.println("12345.675 -> " + numberFormat.format(12345.675));
---------- END SOURCE ----------
FREQUENCY : always
RoundingMode.HALF_UP gives different results with NumberFormat
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the provided code. You will see the following output:
0.675 -> 0.68
12345.675 -> 12,345.67
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
0.675 -> 0.68
12345.675 -> 12,345.68
---------- BEGIN SOURCE ----------
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
numberFormat.setMaximumFractionDigits(2);
numberFormat.setMinimumFractionDigits(2);
numberFormat.setRoundingMode(RoundingMode.HALF_UP);
System.out.println("0.675 -> " + numberFormat.format(0.675));
System.out.println("12345.675 -> " + numberFormat.format(12345.675));
---------- END SOURCE ----------
FREQUENCY : always
- relates to
-
JDK-8062013 DecimalFormat / rounding / HALF_UP
- Closed
- links to
-
Review(master) openjdk/jdk/20580