Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4691683
Votes 0
Synopsis DecimalFormat scientific notation with prefix produces nonsense
Category java:classes_text
Reported Against 1.4
Release Fixed
State 11-Closed, duplicate of 4838107, bug
Priority: 4-Low
Related Bugs 4838107
Submit Date 25-MAY-2002
Description




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 :

 customer  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) 
======================================================================
Work Around
N/A
Evaluation
This is a duplicate of 4838107. Will be fixed in Tiger.
  xxxxx@xxxxx   2003-04-21
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang