Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
|
Relates :
|
FULL PRODUCT VERSION : java version "1.8.0-ea" Java(TM) SE Runtime Environment (build 1.8.0-ea-b118) Java HotSpot(TM) 64-Bit Server VM (build 25.0-b60, mixed mode) ADDITIONAL OS VERSION INFORMATION : Linux Studio-XPS-9100 3.2.0-31-generic #50-Ubuntu SMP Fri Sep 7 16:16:45 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux A DESCRIPTION OF THE PROBLEM : A NumberFormat object with the RoundingMode set to HALF_EVEN rounds correctly in jdk 1.7, but no longer rounds in jdk 1.8. Code for a test case is given in the Steps to Reproduce REGRESSION. Last worked in version 7u40 ADDITIONAL REGRESSION INFORMATION: Broken version: java version "1.8.0-ea" Java(TM) SE Runtime Environment (build 1.8.0-ea-b118) Java HotSpot(TM) 64-Bit Server VM (build 25.0-b60, mixed mode) Previous, working version: java version "1.7.0_40" Java(TM) SE Runtime Environment (build 1.7.0_40-b43) Java HotSpot(TM) 64-Bit Server VM (build 24.0-b56, mixed mode) STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : The following test will print "55.6%" in jdk 1.7 (which is correct) but will print "55.5%" in jdk 1.8 (incorrect). import java.text.NumberFormat; import java.math.RoundingMode; public class NumberFormatTest { public static void main(String[] args) { NumberFormat percent = NumberFormat.getPercentInstance(); percent.setMinimumFractionDigits(1); percent.setMaximumFractionDigits(1); percent.setRoundingMode(RoundingMode.HALF_EVEN); System.out.println(0.5555); System.out.println(percent.format(0.5555)); } } EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - print "55.6%" ACTUAL - prints "55.5%" REPRODUCIBILITY : This bug can be reproduced always.
|