Monetize your website with Chitika eMiniMalls
Powered by MaxBlogPress 

Would you like to get paid for signing up for a web hosting plan with Bluehost.com?
Powered by MaxBlogPress 

C# quick example of handling Infinity and NaN

Posted on April 26, 2009
Filed Under Programming | Leave a Comment

If you've enjoyed reading this post then please subscribe to my Full Text RSS Feed.

prog

In C# programming you may come across instances where you have to compute numbers especially division of numbers which will return a NaN (Not a Number) or Infinity, when dividing by zero.

You can use two methods to check if a number is NaN of Infinity. The two methods are IsNaN and IsInfinity.

Here are the examples:

IsNaN

if (double.IsNaN(per))
{
per = 0.0;
}

IsInfinity

if (double.IsInfinity(per)) {
per = 100;
}

Bookmark and Share
Sphere: Related Content

Other Related Posts:

  • How safe is your Safari browser?
  • Twitter Weekly Updates for 2009-05-03
  • Quick guide on how to take screenshots on a Mac
  • Spamvertised URL
  • Quikpod for DSLR

  • If you've enjoyed reading this post then why not subscribe to received updates by email.

    Enter your email address:

    Delivered by FeedBurner

    Email This Post Email This Post

    Trackback This Post

    Comments

    Leave a Reply




    CommentLuv Enabled

    Twitter

    Posting tweet...

    Powered by Twitter Tools