Name: nt126004 Date: 05/24/2002
FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version 5.00.2195]
Service Pack 2
EXTRA RELEVANT SYSTEM CONFIGURATION :
Should be irrelevant for core package
A DESCRIPTION OF THE PROBLEM :
When creating a DecimalFormat with the
pattern "+0.00000E00", i get results like "+0.98765E-+01"
which is completly senseless in mathematical and expected
manner.
Test 1: 1.23456 --> +1,23456E+00
Test 2: 0.98765 --> +9,87650E-+01
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Execute this code:
import java.text.*;
public class DecimalFormatBugTest {
public static void main(String[] arguments) {
DecimalFormat decimalFormat = new DecimalFormat("+0.00000E00");
double testValue1 = 1.23456d;
double testValue2 = 0.98765d;
System.out.println("Test 1: " + testValue1 + " --
> " + decimalFormat.format(testValue1));
System.out.println("Test 2: " + testValue2 + " --
> " + decimalFormat.format(testValue2));
}
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
Expected:
Test 1: 1.23456 --> +1,23456E00 or +1,23456E+00 (second
using the workaround, i WANT the explicit "+" in the
exponential part)
Test 2: 0.98765 --> +9,87650E-01
Actual:
Test 1: 1.23456 --> +1,23456E+00
Test 2: 0.98765 --> +9,87650E-+01
See the second actual output: Senseless and NOT given in
the formatting pattern.
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.text.*;
public class DecimalFormatBugTest {
public static void main(String[] arguments) {
DecimalFormat decimalFormat = new DecimalFormat("+0.00000E00");
double testValue1 = 1.23456d;
double testValue2 = 0.98765d;
System.out.println("Test 1: " + testValue1 + " --> " +
decimalFormat.format(testValue1));
System.out.println("Test 2: " + testValue2 + " --> " +
decimalFormat.format(testValue2));
}
}
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
Nasty workaround: String manipulation
(Review ID: 145714)
======================================================================