classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mauve results posted nightly


From: Stephen Crawley
Subject: Re: mauve results posted nightly
Date: Fri, 15 Nov 2002 12:23:53 +1000

> Perhaps japize 
> should use Double.doubleToLongBits() to compare the bitwise value of 
> double constants (likewise Float.floatToIntBits()).

That would be a bit safer, considering that even JDK 1.4.x has minor
bugs in its implementations of double -> string translation!  However,
even comparing the bits returned Double.doubleToLongBits() is not
strictly correct, because the Java VM spec says that VMs are allowed to
use a range of bit patterns to represent NaN values.  

The safest way for for japize to compare Java doubles (and floats) is to 
do the following:

   double d1, d2;
   ...
   boolean sameValue = (Double.isNaN(d1) && Double.isNaN(d2)) || (d1 == d2)

Note: you have to test NaNs separately because the Java VM spec says that
(NaN == NaN) always gives false!!

-- Steve





reply via email to

[Prev in Thread] Current Thread [Next in Thread]