-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.1.3, 1.1.6, 1.2.0
-
x86, sparc
-
solaris_2.5, windows_nt
Name: dfC67450 Date: 01/26/98
java.text.DecimalFormat.format(long n, StringBuffer str, FieldPosition fp) formats
wrong if `n * multiplier' greater than Long.MAX_VALUE.
Here is the test demonstrating the bug:
-----------------Test.java------------------------
import java.text.*;
import java.math.*;
public class Test {
public static void main (String args[]){
DecimalFormat df = new DecimalFormat();
long n = 1234567890123456L;
int m = 12345678;
BigInteger bigN = BigInteger.valueOf(n);
bigN = bigN.multiply(BigInteger.valueOf(m));
df.setMultiplier(m);
df.setGroupingUsed(false);
System.out.println("formated: " +
df.format(n, new StringBuffer(), new FieldPosition(0)));
System.out.println("expected: " + bigN.toString());
}
}
---------Output from the test---------------------
formated: 15241577640603568000000
expected: 15241577640603568023168
--------------------------------------------------
======================================================================
- duplicates
-
JDK-4155343 DecimalFormat.format: build-in limitations not specified
-
- Closed
-
-
JDK-4212074 format function of NumberFormat/DecimalFormat
-
- Closed
-
-
JDK-4018937 API: DecimalFormat formats BigDecimal incorrectly
-
- Resolved
-