• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

about == equals

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check out the API Spec for Double. In particular, check out the description of the equals() method.
Corey
 
reply
    Bookmark Topic Watch Topic
  • New Topic