aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes 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 "NaN" Watch "NaN" New topic
Author

NaN

Stephanie Grasson
Ranch Hand

Joined: Jun 14, 2000
Posts: 347
I just got the RHE Java2 Certification study guide.
I was surprised to see that a double divided by 0 is equal to Double.NEGATIVE_INFINITY. All other books I had read said that a double divided by 0 was equal to Double.NaN.
Now I am curious. What sort of operation would result in Double.NaN?
cata lin
Ranch Hand

Joined: May 11, 2000
Posts: 44
Hi,
Try
System.out.println(Math.sqrt(-1.0));
Note that it does not throw any exception.
Stephanie Grasson
Ranch Hand

Joined: Jun 14, 2000
Posts: 347
Thanks Cata Lin.
That makes a lot of sense.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: NaN