toString-ing floats and doubles

Stuart Ballard sballard at
Wed Jun 28 08:34:39 PDT 2000

Is the conversion from a float or double to a String in Java supposed to
be 100% deterministic and give identical results from one implementation
to another?

I notice that System.out.println(Math.E) gives a slightly different
result under Kaffe from JDK1.1, and since Math.E is a compiletime
constant, I know I'm printing the value that my code was *compiled*
against, so the problem isn't just that Kaffe defines E slightly
differently than JDK. A similar result occurs with Math.PI, or any other
float/double constant.

Trivial and obvious sample code:
public class TestE {
  public static void main(String[] args) {

Compile it (against either JDK or Kaffe) and then run the same bytecode
against both Kaffe and JDK. Kaffe's output:

JDK1.1 output:

Thanks in advance,

More information about the kaffe mailing list