• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

About NAN  RSS feed

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,everyone, Why the result is false??


Thanks advance!!
 
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
0.0/0.0 is NaN and NaN is different from 0. Hence false.
 
Xiao Song
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot.
In rt.jar NaN is defined as follows:


A constant holding the largest positive finite value of type
double,It is equal to the hexadecimal floating-point literal
0x1.fffffffffffffP+1023 and also equal to
Double.longBitsToDouble(0x7fefffffffffffffL)



What is this mean??
 
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ranchers,
Xiao Song posted November 20, 2006 01:39 AM

Hello,everyone, Why the result is false??

when you perform arithmetic operation on NaN the result will also be not a number.
So NaN - NaN = NaN
and NaN is not zero.

Furthermor NaN is unuequal to everything, including itself (this may give you some headaches if you think about it).

eg

prints
NaN
false
true
 
Xiao Song
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Burkhard Hassel, His explonatio is very clear.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!