Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Double.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 "Double.NaN" Watch "Double.NaN" New topic
Author

Double.NaN

rani bedi
Ranch Hand

Joined: Feb 06, 2001
Posts: 358
Can you explain me the output..??


Cheers,<br />Rani<br />SCJP, SCWCD, SCBCD
Hanna Habashy
Ranch Hand

Joined: Aug 20, 2003
Posts: 532
hi:
NaN is a constant holding a Not-a-Number value.
NaN doesn't equal anything, not even itself.
so
Double.NaN == Double.Nan// is false
Your created two objects references of type Double. The bit holders for both references refere to Double.NaN.
Then
a.equal(b) will return true


SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12792
    
    5
It is instructive to look at the source for java.lang.Double - look at the method for equals and for isNaN.
Everybody studying for the exam should have the source (unzip src.zip) and study it when these questions come up.
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Double.NaN