/**
* Returns {@code true} if the specified number is a
* Not-a-Number (NaN) value, {@code false} otherwise.
*
* @param v the value to be tested.
* @return {@code true} if the value of the argument is NaN;
* {@code false} otherwise.
*/
public static boolean isNaN(double v) {
return (v != v);
}
OpenJDK8からとってきたこのコード…。
とても不思議に感じてしまう。
vの値が NaN の場合、NaN == NaNがfalse、NaN != NaNがtrueになるらしい…