• 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:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

NaN and '=='

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

The following is from Dan Chisholm's.
The output is: true false true.
Can anyone explain the practical advantage of the following behaviour regarding *.NaN and '=='?
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
NAN is not equal to anything including itself. So

(NAN == NAN) will result in false.

Fes
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For an explanation I can only suggest reading the IEEE 754 Standard and the Java Language Specification. There are also interesting documents on the Web if you search for them. Those programmers who are involved in scientific computing need to know this stuff, but for a large number of commercial applications it is not necessary to go into such detail. It is certainly not necessary for SCJP 5.0.

What I love most is Double.NaN != Double.NaN is true
 
reply
    Bookmark Topic Watch Topic
  • New Topic