Problem :
When printing a float or double as a String, the resulting string
interpretation of the value is wrong (i.e. not close to the original
value) and it contains non-numeric characters.
Below is a session log that contains:
A cat of a simple program called WriteTest
The results of the execution of WriteTest
The results of java –version
<<< Log from MSISR started September 20, 2006, 17:12:45 >>>
:JAVA# cat
WriteTest.java
class WriteTest
{
public WriteTest()
{
super
();
}
public static void main(java.lang.String[] args)
{
double doubleValue = (double)
0.123456789;
float floatValue = (float)
0.123456;
System.out.println("Double Value = "+doubleValue+" Float
Value
= "+floatValue);
}
}
:JAVA# java
WriteTest
Double Value = 0.=75073800938646879 Float Value =
0.070:679
:JAVA# java -
version
java
version "1.4.2"
JamVM version
1.4.3
Copyright (C) 2003-2006 Robert Lougher
<org.uk>
:JAVA#
<<< Log from MSISR ended September 20, 2006, 17:14:07 >>>
NOTES :
The value stored in the variable appears to be correct. The actual
program I was running when I found this problem seems to receive the
correct double or float value when used in computations. The error
appears to be in the toString() method.
I had originally installed the stable version of JamVM on the TS-
7300, but it had lots of problems. At first I thought it was the
java application, but the same application has run without problems
on many other java runtimes, including the IBM j9 that I used on an
ARCOM Vulcan PC104 CPU. One of the items that jumped out at me was
that the file separator was coming up as a ":" instead of a "/".
Once I saw that, I installed the testing version of JamVM. Now
everything works correctly except the items noted here (or at least
I should say I haven't found any other problems). I also tried
SableVM. It performed exactly the same.
I've run the WriteTest application on several other platforms with
different runtimes, and it works correctly on all.
I've submitted this as a bug report to the Debian folks and have
recieved no reply.
Thanks for any help. I'm busy trying work-arounds, such as :
(new Double(doubleValue)).toString()
But that produces the same results.
Please contact me if you need any additional information. I'll be
in a real Jam (no pun intended) if I can't get this to work.