aspose file tools
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


Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
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: 12868
    
    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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Double.NaN