This is the mail archive of the
mauve-discuss@sources.redhat.com
mailing list for the Mauve project.
Bug in DoubleTest/FloatTest?
- From: Andrew Haley <aph at redhat dot com>
- To: Stephen Crawley <crawley at dstc dot edu dot au>
- Cc: mauve-discuss at sources dot redhat dot com
- Date: Fri, 27 Sep 2002 16:35:56 +0100 (BST)
- Subject: Bug in DoubleTest/FloatTest?
- References: <200209271530.g8RFUD4s025073@piglet.dstc.edu.au>
Stephen Crawley writes:
>
> Folks,
>
> I've found another possible bug in DoubleTest (& FloatTest). The problem
> shows up when I use JDK 1.3.1 and JDK 1.4.0 to run the Mauve test suite.
> Specifically, the following subtest fails:
>
> str = Double.toString( 0.001 );
> if ( !Double.toString( 0.001 ).equals ("0.001" )) {
> harness.fail("Error: test_toString failed - 10" );
> System.out.println("Expected: " + "0.001");
> System.out.println("Got: " + Double.toString(0.001));
> }
>
> printing out that it got "0.0010" instead of "0.001". By contrast,
> the standard Classpath implementation does not fail this subtest.
Right. The JDK has done this for a long while.
> But it gets worse. The JDK 1.4.0 javadoc states that toString()
> should output enough digits to distinguish the double from other
> doubles ... BUT NO MORE. In this case, the final digit of "0.0010"
> is not necessary. Basically, both Sun JDK implementations I tried do
> not match the javadoc.
>
> What do we do?
>
> 1) Change the subtest to match the JDK behaviour (not the javadoc)?
> The implication is that Classpath should be changed to duplicate
> the bug.
No.
> 2) Modify the subtest to accept both "0.001" and "0.0010"?
No.
> 3) Remove the subtest?
No.
> 4) Leave it alone.
Yes: the JDK does not meet its specfication.
Andrew.