Current Status:<br /> <br />SCJP 1.4<br />SCJD (in progress)
Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Current Status:<br /> <br />SCJP 1.4<br />SCJD (in progress)
Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
The exceptions are C predicates � x == x � and � x != x �, which are respectively 1 and 0 for every
infinite or finite number x but reverse if x is Not a Number ( NaN ); these provide the only simple unexceptional
distinction between NaNs and numbers in languages that lack a word for NaN and a predicate IsNaN(x). Overoptimizing
compilers that substitute 1 for x == x violate IEEE 754.
IEEE 754 assigns values to all relational expressions involving NaN . In the syntax of C , the predicate
x != y is True but all others, x < y , x <= y , x == y , x >= y and x > y , are False whenever
x or y or both are NaN, and then all but x != y and x == y are INVALID operations too and must so
signal. Ideally, expressions x !< y , x !<= y , x !>= y , x !> y and x !>=< y should be valid and
quietly True if x or y or both are NaN , but arbiters of taste and fashion for ANSI Standard C have refused to
recognize such expressions. In any event, !(x < y) differs from x >= y when NaN is involved, though
rude compilers � optimize � the difference away. Worse, some compilers mishandle NaNs in all relational
expressions.
If the argument is any value in the range 0x7ff0000000000001L through 0x7fffffffffffffffL or in the range 0xfff0000000000001L through 0xffffffffffffffffL, the result is a NaN.
Mike Gershman
SCJP 1.4, SCWCD in process
Has anybody tried this :
System.out.println(((new Double(Double.NaN)).equals(new Double(Double.NaN))));
Ans: True
Mike Gershman
SCJP 1.4, SCWCD in process
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |