Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

According to the JLS, §4.2.3, "Floating-Point Types, Formats, and Values" [JLS 2005]:

NaN (not-a-number) is unordered, so the numerical comparison operators <, <=, >, and >= return false if either or both operands are NaN. The equality operator == returns false if either operand is NaN, and the inequality operator != returns true if either operand is NaN.

...

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

...

NUM06-J. Use the strictfp modifier for floating-point calculation consistency across platforms      Rule 03: Numeric Types and Operations (NUM)Image Added