aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes NaN and '==' Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "NaN and Watch "NaN and New topic
Author

NaN and '=='

Joseph Clark
Ranch Hand

Joined: Sep 10, 2005
Posts: 48
Hi,

The following is from Dan Chisholm's.
The output is: true false true.
Can anyone explain the practical advantage of the following behaviour regarding *.NaN and '=='?
Fes D Gaur
Ranch Hand

Joined: Apr 29, 2005
Posts: 54
NAN is not equal to anything including itself. So

(NAN == NAN) will result in false.

Fes
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
For an explanation I can only suggest reading the IEEE 754 Standard and the Java Language Specification. There are also interesting documents on the Web if you search for them. Those programmers who are involved in scientific computing need to know this stuff, but for a large number of commercial applications it is not necessary to go into such detail. It is certainly not necessary for SCJP 5.0.

What I love most is Double.NaN != Double.NaN is true


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NaN and '=='