...
Because this unordered property is often unexpected, direct comparisons with NaN
must not be performed. Problems can arise when programmers write code that compares floating-point values without considering the semantics of NaN
. For example, input validation checks that fail to consider the possibility of a NaN
value as input can produce unexpected results. See rule NUM08-J. Check floating-point inputs for exceptional values for additional information.
Noncompliant Code Example
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="a3ed807bb76f7597-6eb735cf-41c74656-9c4fa583-c31046fe344b3c66ef97a13c"><ac:plain-text-body><![CDATA[ | [[FindBugs 2008 | AA. Bibliography#FindBugs 08]] | FE: Doomed test for equality to NaN | ]]></ac:plain-text-body></ac:structured-macro> | |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="787d27ad9831991d-7bad34e0-464143d5-ae96b1f9-68eb57bc80661fd17179f280"><ac:plain-text-body><![CDATA[ | [[JLS 2005 | AA. Bibliography#JLS 05]] | [§4.2.3, Floating-Point Types, Formats, and Values | http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.2.3] | ]]></ac:plain-text-body></ac:structured-macro> |
...