Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

When will we get the value [B]NaN[/B].

 
pradeep singh
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to all,
When will we get the value NaN.Please explain me with examples?
 
pradeep singh
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please anyone give your valuable thoughts about above
 
Thirugnanam Saravanan
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"NaN" stands for "Not a Number". "NaN" is produced if a floating point operation has some input parameters that cause the operation to produce some undefined result. For example, 0.0 divided by 0.0 is arithmetically undefined. Taking the square root of a negative number is also undefined.

0.0 / 0.0 -> NaN
Math.sqrt(-2.0) -> NaN


Refer The following example:

 
pradeep singh
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot,Mr.Thirugnanam Saravanan
Now i am well understood.
Thanks again.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic