-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
8u25
-
x86_64
-
windows_xp
FULL PRODUCT VERSION :
java.text.DecimalFormat
ADDITIONAL OS VERSION INFORMATION :
Windows 7
A DESCRIPTION OF THE PROBLEM :
The program below prints 576.34 instead of 576.35 as in Java 6
import java.math.RoundingMode;
import java.text.DecimalFormat;
public class Main {
public static void main(String[] args) {
DecimalFormat amountFormatter = new DecimalFormat( "0.00" );
Double d = 576.34700000;
amountFormatter.setRoundingMode(RoundingMode.HALF_UP);
String standardizedAmount = amountFormatter.format(d);
System.out.println(standardizedAmount);
}
}
REGRESSION. Last worked in version 6u43
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run program below
import java.math.RoundingMode;
import java.text.DecimalFormat;
public class Main {
public static void main(String[] args) {
DecimalFormat amountFormatter = new DecimalFormat( "0.00" );
Double d = 576.34700000;
amountFormatter.setRoundingMode(RoundingMode.HALF_UP);
String standardizedAmount = amountFormatter.format(d);
System.out.println(standardizedAmount);
}
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
576.35
ACTUAL -
576.34
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.math.RoundingMode;
import java.text.DecimalFormat;
public class Main {
public static void main(String[] args) {
DecimalFormat amountFormatter = new DecimalFormat( "0.00" );
Double d = 576.34700000;
amountFormatter.setRoundingMode(RoundingMode.HALF_UP);
String standardizedAmount = amountFormatter.format(d);
System.out.println(standardizedAmount);
}
}
---------- END SOURCE ----------
SUPPORT :
YES
java.text.DecimalFormat
ADDITIONAL OS VERSION INFORMATION :
Windows 7
A DESCRIPTION OF THE PROBLEM :
The program below prints 576.34 instead of 576.35 as in Java 6
import java.math.RoundingMode;
import java.text.DecimalFormat;
public class Main {
public static void main(String[] args) {
DecimalFormat amountFormatter = new DecimalFormat( "0.00" );
Double d = 576.34700000;
amountFormatter.setRoundingMode(RoundingMode.HALF_UP);
String standardizedAmount = amountFormatter.format(d);
System.out.println(standardizedAmount);
}
}
REGRESSION. Last worked in version 6u43
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run program below
import java.math.RoundingMode;
import java.text.DecimalFormat;
public class Main {
public static void main(String[] args) {
DecimalFormat amountFormatter = new DecimalFormat( "0.00" );
Double d = 576.34700000;
amountFormatter.setRoundingMode(RoundingMode.HALF_UP);
String standardizedAmount = amountFormatter.format(d);
System.out.println(standardizedAmount);
}
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
576.35
ACTUAL -
576.34
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.math.RoundingMode;
import java.text.DecimalFormat;
public class Main {
public static void main(String[] args) {
DecimalFormat amountFormatter = new DecimalFormat( "0.00" );
Double d = 576.34700000;
amountFormatter.setRoundingMode(RoundingMode.HALF_UP);
String standardizedAmount = amountFormatter.format(d);
System.out.println(standardizedAmount);
}
}
---------- END SOURCE ----------
SUPPORT :
YES
- duplicates
-
JDK-8039915 Wrong NumberFormat.format() HALF_UP rounding when last digit exactly at rounding position greater than 5
- Closed