When performing the operation, the result of which is not defined mathematically (root of a negative number, 0.0 / 0.0, etc.) returns the special value NaN (Not a Number, not a number). In the wrapper-class of fractional numbers the corresponding constants are declared: Float.NaN and Double.NaN.
A feature of value NaN is that in any arithmetic operations with it it also turns NaN, but when you try to compare it to anything with == it always gets false.
If you want to check whether a value is NaN, then you need to use the methods Float.isNaN (float) or Double.isNaN (double).
Login in to like
Login in to comment