Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

NaN  RSS feed

 
Stephanie Grasson
Ranch Hand
Posts: 347
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Try
System.out.println(Math.sqrt(-1.0));
Note that it does not throw any exception.
 
Stephanie Grasson
Ranch Hand
Posts: 347
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Cata Lin.
That makes a lot of sense.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!