Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
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 -------------------------------------------------- ======================================================================
|