ADDITIONAL SYSTEM INFORMATION :
OSX, JDK 12,8
A DESCRIPTION OF THE PROBLEM :
Wrong rounding in formatter:
double v3 = 0.00024649999999999997d;
System.out.println(String.format("%.6f", v3));
System.out.println(String.format("%.7", v3));
0.000247 (incorrect)
0.0002465
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
double v3 = 0.00024649999999999997d;
System.out.println(String.format("%.6f", v3));
System.out.println(String.format("%.7f", v3));
double v2 = .0002755d;
System.out.println(new DecimalFormat("#.######").format(v2));
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
0.000246
ACTUAL -
0.000247
---------- BEGIN SOURCE ----------
double v3 = 0.00024649999999999997d;
System.out.println(String.format("%.6f", v3));
System.out.println(String.format("%.7f", v3));
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
BigDecimal maybe, but it's slow
FREQUENCY : always
OSX, JDK 12,8
A DESCRIPTION OF THE PROBLEM :
Wrong rounding in formatter:
double v3 = 0.00024649999999999997d;
System.out.println(String.format("%.6f", v3));
System.out.println(String.format("%.7", v3));
0.000247 (incorrect)
0.0002465
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
double v3 = 0.00024649999999999997d;
System.out.println(String.format("%.6f", v3));
System.out.println(String.format("%.7f", v3));
double v2 = .0002755d;
System.out.println(new DecimalFormat("#.######").format(v2));
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
0.000246
ACTUAL -
0.000247
---------- BEGIN SOURCE ----------
double v3 = 0.00024649999999999997d;
System.out.println(String.format("%.6f", v3));
System.out.println(String.format("%.7f", v3));
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
BigDecimal maybe, but it's slow
FREQUENCY : always
- relates to
-
JDK-7131459 [Fmt-De] DecimalFormat produces wrong format() results when close to a tie
- Closed