Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Double.NaN  RSS feed

 
rani bedi
Ranch Hand
Posts: 358
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you explain me the output..??
 
Hanna Habashy
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!