This is the mail archive of the mauve-discuss@sources.redhat.com 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 [mailto:peter@erble.freeserve.co.uk]
Sent: Tuesday, July 11, 2000 3:46 PM
Cc: mauve-discuss@sourceware.cygnus.com
Subject: Re: Float.toString test


In message <BE97ACF1A2EB464886E1DAF6C51BAC6E31E689@DF-SPOT.platinum.corp.microsoft.com>
          "Xubin Wu (Volt Computer)" <a-xubinw@Exchange.Microsoft.com> wrote:

> c:\mauve-snapshot-2000-06-17>echo
> gnu.testlet.java.lang.Float.FloatTest|java gnu.testlet.SimpleTestHarness
> gnu.testlet.java.lang.Float.FloatTest
> FAIL: gnu.testlet.java.lang.Float.FloatTest: 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



--
------------------------------------------------------------------------
 Peter Naulls - peter@erble.freeserve.co.uk
 Homepage - http://free.prohosting.com/~chocky/
 Java for RISC OS and ARM - http://free.prohosting.com/~chocky/java/
 Debian Linux on RiscPCs - http://www.erble.freeserve.co.uk/
------------------------------------------------------------------------

ToString.java


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