File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes About NAN Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "About NAN" Watch "About NAN" New topic
Author

About NAN

Xiao Song
Greenhorn

Joined: Aug 29, 2006
Posts: 17
Hello,everyone, Why the result is false??


Thanks advance!!


scjping.......
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

0.0/0.0 is NaN and NaN is different from 0. Hence false.


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Xiao Song
Greenhorn

Joined: Aug 29, 2006
Posts: 17
Thanks a lot.
In rt.jar NaN is defined as follows:


A constant holding the largest positive finite value of type
double,It is equal to the hexadecimal floating-point literal
0x1.fffffffffffffP+1023 and also equal to
Double.longBitsToDouble(0x7fefffffffffffffL)


What is this mean??
Burkhard Hassel
Ranch Hand

Joined: Aug 25, 2006
Posts: 1274
Hi ranchers,
Xiao Song posted November 20, 2006 01:39 AM
Hello,everyone, Why the result is false??
when you perform arithmetic operation on NaN the result will also be not a number.
So NaN - NaN = NaN
and NaN is not zero.

Furthermor NaN is unuequal to everything, including itself (this may give you some headaches if you think about it).

eg

prints
NaN
false
true


all events occur in real time
Xiao Song
Greenhorn

Joined: Aug 29, 2006
Posts: 17
Thanks Burkhard Hassel, His explonatio is very clear.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: About NAN
 
Similar Threads
incompatible types: found double required float error;
confusion on (==)
Doubt in Math class
Majji question-Comparision results
Math min,max