This is the mail archive of the mailing list for the Mauve project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Float.toString test

Title: RE: Float.toString test

I rewrite the testcase for only test Float.toString() and Double.toString()method. And I found only if the input value is 0.001f or 0.001 (double), I get the error. But when the input is 0.01f or 0.01, the result is correct. Are the 0.001f or 0.001 magic numbers which only I can use to get the error ?

see attach.
Here is result for java1.2.2 on NT .
C:\MAUVE_~1\java.lang.float>java ToString
Float.toString(0.001f)= 0.0010
Error: test_toString failed - 3
Double.toString(0.001)= 0.0010
Error: test_toString failed - 4
Tests 2/4   fails

-----Original Message-----
From: Peter Naulls []
Sent: Tuesday, July 11, 2000 3:46 PM
Subject: Re: Float.toString test

In message <>
          "Xubin Wu (Volt Computer)" <> wrote:

> c:\mauve-snapshot-2000-06-17>echo
>|java gnu.testlet.SimpleTestHarness
> FAIL: Error: test_toString failed
> - 10 (number 1)
> 1 of 68 tests failed
> when I run FloatTest, one test case fails which is
>               str = Float.toString( 0.001f );
>               harness.check(!( !Float.toString( 0.001f ).equals
> ("0.001" )),
>                       "Error: test_toString failed - 10" );
> it returns 0.0010, not 0.001.
> When I passed Float.toString( 0.01f ), it returns 0.01.
> Does anybody think it is a bug, or something else.

It looks like a bug.  The 1.1 toString method in java.lang.Float
suggest that values in that range should be in a ddd.ddd style:
I'm not sure about Java 1.2, but I recall in 1.0.2 this was more lax -
and that the behaviour of Sun's 1.0.2 JVM didn't quite match the API.


 Peter Naulls -
 Homepage -
 Java for RISC OS and ARM -
 Debian Linux on RiscPCs -

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]