Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

about == equals

 
krussi rong
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
here is the question:
Double a = new Double(Double.NaN);
Double b = new Double(Double.NaN);
if(Double.NaN == Double.NaN)
System.out.println("True");
else
System.out.println("False");
if(a.equals(b))
System.out.println("True");
else
System.out.println("False");

So why the answer is False
True.
if Double.NaN == Double.NaN is False,
How the a.equals(b) comes True.
and I really don't know why Double.NaN == Double.NaN if False. and what is NaN?
Thanks
Krussi
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the API Spec for Double. In particular, check out the description of the equals() method.
Corey
 
Think of how stupid the average person is. And how half of them are stupider than that. But who reads this tiny ad?
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!