FULL PRODUCT VERSION :
A DESCRIPTION OF THE PROBLEM :
teh problem happens rounding a number using the DecimalFormat class using setRoundingMode method and formating. Teh result of this format using RoundigMode.HALF_UP results in a down rounding. The best way to describe the error is through an example.
Using this code:
DecimalFormat df = new DecimalFormat("#.00");
df.setRoundingMode(RoundingMode.HALF_UP);
String result = df.format(12.465d);
In java 6 result is 12.47
in java 8 result is 12.46
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
The best way to describe the error is through an example.
Using this code:
DecimalFormat df = new DecimalFormat("#.00");
df.setRoundingMode(RoundingMode.HALF_UP);
String result = df.format(12.465d);
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
DecimalFormat df = new DecimalFormat("#.00");
df.setRoundingMode(RoundingMode.HALF_UP);
String result = df.format(12.465d);
---------- END SOURCE ----------
A DESCRIPTION OF THE PROBLEM :
teh problem happens rounding a number using the DecimalFormat class using setRoundingMode method and formating. Teh result of this format using RoundigMode.HALF_UP results in a down rounding. The best way to describe the error is through an example.
Using this code:
DecimalFormat df = new DecimalFormat("#.00");
df.setRoundingMode(RoundingMode.HALF_UP);
String result = df.format(12.465d);
In java 6 result is 12.47
in java 8 result is 12.46
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
The best way to describe the error is through an example.
Using this code:
DecimalFormat df = new DecimalFormat("#.00");
df.setRoundingMode(RoundingMode.HALF_UP);
String result = df.format(12.465d);
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
DecimalFormat df = new DecimalFormat("#.00");
df.setRoundingMode(RoundingMode.HALF_UP);
String result = df.format(12.465d);
---------- END SOURCE ----------
- duplicates
-
JDK-7131459 [Fmt-De] DecimalFormat produces wrong format() results when close to a tie
-
- Closed
-