• 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
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Math.min

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this code is from the http://www.angelfire.com/or/abhilash/Main.html :
System.out.println(Math.min(Float.NaN, Float.POSITIVE_INFINITY));
the result gives
NaN
1-can anyone explain to me why NaN ?
2- do we get questions like this in the exam?
Thanks
 
Ranch Hand
Posts: 1880
Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
NaN-NotaNumber
u can get like these questions in the exams
when u trying to do any arithmetic operations like
0.0/0.0
0.0/-0.0
0/0.0
Math.sqrt(-1) // we cannot find sqrt for negative number
i will always give NaN
anything comparison with NaN always will return false
eg:
(Float.NaN==Float.NaN) will return false
OK bye,
 
He baked a muffin that stole my car! And this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic