I am wondering if this question can be solved in Java (I\'m new to the language). This is the code:
class Condition {
// you can change in the main
p
The replaced line could read.
double x = Double.NaN;
This would cause the gotcha to be printed.
Java Language Specification (JLS) says:
Floating-point operators produce no exceptions (§11). An operation that overflows produces a signed infinity, an operation that underflows produces a denormalized value or a signed zero, and an operation that has no mathematically definite result produces NaN. All numeric operations with NaN as an operand produce NaN as a result. As has already been described, NaN is unordered, so a numeric comparison operation involving one or two NaNs returns false and any != comparison involving NaN returns true, including x!=x when x is NaN.