Conversion of a double value (and perhaps a float) to String
can result in more digits than are absolutely necessary, contrary to the JLS.
Attached is mail giving an number of good examples.
Name: yyT116575 Date: 03/13/2001
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
Execute the following class:
public strictfp class Test
{
static public void main(String [] arg)
{
float f = 23.56f;
double d = f;
System.out.println(f + " " + d);
}
}
The result is:
23.56 23.559999465942383
It seems that the results contradicts Java specification that explicitly says
that conversion from float to double in a strctfp expression should not lose
precision
(Review ID: 118747)
======================================================================
###@###.### 2004-11-11 21:43:45 GMT