commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles Sadowski <gil...@harfang.homelinux.org>
Subject Re: [math] removing the two asserts in MathUtils.equals(double, double, int) and MathUtils.equals(float, float, int)
Date Sun, 10 Apr 2011 20:48:47 GMT
Hello Luc.

> [...]
> 
> I propose to change the  "maxUlps > 0" into "maxUlps >= 0" and either
> 
>  1) comment out the corresponding asserts (just as the other ones in
>     the file are commented out)
>  2) replace the asserts by a real test and throw a
>     MathIllegalArgumentException
>  3) remove the asserts without replacement
> 
> I would prefer choice 1.
> 
> What do you think ?

The line with the "assert" was a remnant from the original code:
  http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
where a paragraph warns about the caveat related to NaNs.

I think that this is in effect handled with the last line of the Java code:
-----
    return isEqual && !Double.isNaN(x) && !Double.isNaN(y);
-----

Thus, the assert not necessary.
Option 3) would be fine, I think.


Gilles

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message