Use the static Double.isNaN(double)
method, or your Double
's .isNaN()
method.
// 1. static method if (Double.isNaN(doubleValue)) { ... } // 2. object's method if (doubleObject.isNaN()) { ... }
Simply doing:
if (var == Double.NaN) { ... }
is not sufficient due to how the IEEE standard for NaN and floating point numbers is defined.