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
• Ron McLeod
• Paul Clapham
• Devaka Cooray
• Liutauras Vilda
Sheriffs:
• Jeanne Boyarsky
• paul wheaton
• Henry Wong
Saloon Keepers:
• Stephan van Hulst
• Tim Holloway
• Tim Moores
• Carey Brown
• Mikalai Zaikin
Bartenders:
• Lou Hamers
• Piet Souris
• Frits Walraven

# doubt reg NaN (from JLS)

Ranch Hand
Posts: 67
• Number of slices to send:
Optional 'thank-you' note:
In JLS section 4.2.3, the following points are given.

NaN is unordered, so the numerical comparison operators <, <=, >, and >= return false if either or both operands are NaN (�15.20.1). The equality operator == returns false if either operand is NaN, and the inequality operator != returns true if either operand is NaN (�15.21.1). In particular, x!=x is true if and only if x is NaN, and (x<y) == !(x>=y) will be false if x or y is NaN.

I don't get this. can anyone explain?

Author & Gold Digger
Posts: 7617
6
• Number of slices to send:
Optional 'thank-you' note:
In clear, it means that NaN cannot be compared with numbers, that is,
NaN > 3 yields false
3 > NaN yields false
NaN >= 3 yields false
3 >= NaN yields false
NaN < 3 yields false
3 < NaN yields false
NaN <= 3 yields false
3 <= NaN yields false
3 == NaN yields false
3 != NaN yields true
NaN != NaN yields true (!!!)
(NaN < 3) == !(NaN >= 3) yields false
(3 < NaN) == !(3 >= NaN) yields false

Rajeshwari Natarajan
Ranch Hand
Posts: 67
• Number of slices to send:
Optional 'thank-you' note:
thanx a lot..that was a very clear and easy to understand explanation

 Willie Smits increased rainfall 25% in three years by planting trees. Tiny ad: We need your help - Coderanch server fundraiser https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
Similar Threads