According to the JLS, [§4.2.3, "Floating-Point Types, Formats, and Values"|http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.2.3] \[ [JLS 2005|AA. References#JLS 05]\]: Wiki Markup
NaN
(not-a-number) is unordered, so the numerical comparison operators<
,<=
,>
, and>=
returnfalse
if either or both operands areNaN
. The equality operator==
returnsfalse
if either operand isNaN
, and the inequality operator!=
returnstrue
if either operand isNaN
.
...
Automated detection of comparison with NaN is straightforward. Sound determination of whether the possibility of an unordered result has been correctly handled is not feasible in the general case. Heuristic checks could be useful.
Bibliography
...
[[FindBugs 2008AA. References#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="08c62919-e62e-4daa-be2b-6bf774cb0a91"><ac:plain-text-body><![CDATA[ | [ [JLS 2005AA. References#JLS 05]] | http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.2.3] | ]]></ac:plain-text-body></ac:structured-macro> |
...
NUM06-J. Use the strictfp modifier for floating-point calculation consistency across platforms 03. Numeric Types and Operations (NUM)