Duplicate :
|
|
Relates :
|
|
Relates :
|
FULL PRODUCT VERSION : java version "1.8.0_25" Java(TM) SE Runtime Environment (build 1.8.0_25-b18) Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode) ADDITIONAL OS VERSION INFORMATION : Microsoft Windows [Version 6.1.7601] A DESCRIPTION OF THE PROBLEM : Problem with rounding up: DecimalFormat l_format = new DecimalFormat(); l_format.setRoundingMode(RoundingMode.HALF_UP); l_format.setMaximumFractionDigits(2); l_format.getDecimalFormatSymbols().setDecimalSeparator('.'); System.out.println(l_format.format(13.135d)); With 2 fraction digits I think the output must be 13.14, but it is 13.13 even after the fix for Bug-ID: 8039915 (applied in the boot class path with the jdk8-dev sources). REGRESSION. Last worked in version 7u72 STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Just execute the code written in the description. REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- DecimalFormat l_format = new DecimalFormat(); l_format.setRoundingMode(RoundingMode.HALF_UP); l_format.setMaximumFractionDigits(2); l_format.getDecimalFormatSymbols().setDecimalSeparator('.'); assertEquals(13.14d, l_format.format(13.135d)); ---------- END SOURCE ----------
|