
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;
}
Sphere: Related Content







