On to Hydro
Tyler Close
tjclose@yahoo.com
Thu, 17 Aug 2000 07:49:48 -0400
Markm wrote:
> Unless anyone has a good objection, the next release of E
> will continue to
> use the current collection library by default, but will
> also experimentally
> include the 1.0 version of Hydro, so we can start playing
> around with it.
I object. ;) I think you mean the 2.0 version of Hydro. 2.0 is the one
that has the immutable containers. The 1.0 version uses mutable
containers.
> Since Tyler & I both have strong styles, and since these styles are
> different, it'll be interesting seeing what kinds of
> conflicts we have.
> Here's the first one I saw:
>
>
> The contract for Comparison states that it provides a total
> order, but the
> implementation of GreaterDouble (an implementation of
> Comparison) says:
>
> /**
> * Compares the values of two <code>Double</code> objects.
> * @return <code>true</code> if the first <code>Double</code>
> * has a greater value.
> */
> public static
> boolean compare(Double a, Double b)
> {
> return a.doubleValue() > b.doubleValue();
> }
>
> In Java and IEEE, ">" is not a total ordering on floating
> point values.
> Rather,
>
> anything < NaN yields false
>
> and
>
> anything > NaN yields false
This is not a style conflict, it's a bug. I've corrected it (and a
couple others) and posted a new version (Beta2) on my web site at:
http://www.waterken.com/Hydro/2.0/
The new implementation of GreaterDouble is:
public static
boolean compare(Double a, Double b)
{
return a.doubleValue() > b.doubleValue() || (a.isNaN() &&
!b.isNaN());
}
I specified total ordering because I think most programmers are not
prepared to deal with the subtleties between equivalence and equality.
One example of this is a SortedSet of doubles with NaN. If two sets
contain the same elements, you'd expect them to be equal, but they may
not be, depending on when the NaN was inserted. This is just too
surprising.
> Another is "<" for strict subset.
Could you explain this more.
Tyler
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com