All of the API's boolean operator comparisons to Float.NaN or Double.NaN are invalid

Issue #12 resolved
Tim Boylan created an issue

All of the API's boolean operator comparisons to Float.NaN or Double.NaN are invalid.

The equality operator == returns false if either operand is NaN.

The inequality operator != returns true if either operand is NaN .

Even Float.NaN == Float.NaN will return false and

Float.NaN != Float.NaN will return true

You need to use from the Float class: static boolean Float.isNaN(float v)

Returns true if the specified number is a Not-a-Number (NaN) value, false otherwise.

or for double use the corresponding one for Double.

http://www.xyzws.com/javafaq/how-can-you-compare-nan-values/62

Comments (2)

  1. Ashutosh Kumar Singh repo owner

    Hi Tim, Thanks for informing me. You've found many bugs and have been very helpful in this project. It's solved now. Thanks for all. :)

  2. Log in to comment