DecimalFormat.format() misbehaved on my machine



Hi,

I found this description in the API doc:

The number of significant digits in the mantissa is the sum of the
minimum integer and maximum fraction digits, and is unaffected by the
maximum integer digits. For example, 12345 formatted with "##0.##E0"
is "12.3E3".


But when I tried it out, I got different results:
System.out.println(new DecimalFormat("##0.##E0").format(12345)); //
prints 12.345E3

I then took one '#' away from both ends in turn, but still got
unexpected results:
System.out.println(new DecimalFormat("#0.##E0").format(12345)); //
prints 1.234E4
System.out.println(new DecimalFormat("##0.#E0").format(12345)); //
prints 12.34E3

My platform's Win Xp Pro x64 Sp2, and I'm using Java 1.6.

Has anyone else observed the same behavior on different platforms?

Regards,
PS

.



Relevant Pages

  • every number has its own significance.....
    ... 18 is the only number that is twice the sum of its digits. ... 21 is the smallest number of distinct squares needed to tile a square. ... 26 is the only number to be directly between a square and a cube. ... 27 is the largest number that is the sum of the digits of its cube. ...
    (sci.crypt)
  • Re: six six seven
    ... It is also equal to the sum of its digits plus the cubes of its digits: ... 16661 is the first beastly palindromic prime, ... (Also, note that from the two powers, 47 and 51, we get ...
    (alt.sports.football.pro.ne-patriots)
  • [SUMMARY] Checking Credit Cards (#122)
    ... to see how people approached the Luhn algorithm implementation. ... # check specified conditions to determine the type of card ... # sum the resulting digits, mod with ten, check against 0 ... simple sum of the digits and the final modulo test to determine validity. ...
    (comp.lang.ruby)
  • Re: standard deviation, but without the mean
    ... Suppose Xsum is the sum of the the first n numbes and that X2 is ... Just keep track if X2 and Xsum as you go. ... Actually this is not a correct algorithm, ... the error in the least 9 digits.. ...
    (sci.stat.math)
  • Re: Is continuum completely filled up?
    ... This is difinition of the sum of Cauchy sequence. ... The "infinite sum" is not actually a sum. ... I can compare infinite decimals. ... which share those initial digits. ...
    (sci.math)