Single.IsFinite() Method in C# with Examples
Last Updated :
01 May, 2019
Single.IsFinite() Method is used to check whether the float value is out of bound or not.
Syntax: public static bool IsFinite (float value);
Return Value: This method returns the true if value is finite otherwise false.
Below programs illustrate the use of Single.IsFinite() Method:
Example 1:
using System;
using System.Globalization;
class GFG {
public static void Main()
{
float value1 = 1654.268416f;
bool value = Single.IsFinite(value1);
if (value)
Console.WriteLine( "{0} is finite" , value1);
else
Console.WriteLine( "{0} is not finite" , value1);
}
}
|
Output:
1654.268 is finite
Example 2:
using System;
using System.Globalization;
class GFG {
public static void Main()
{
float value1 = ( float )Math.Pow(2, 10000000);
bool value = Single.IsFinite(value1);
if (value)
Console.WriteLine( "{0} is finite" , value1);
else
Console.WriteLine( "{0} is not finite" , value1);
}
}
|
Output:
Infinity is not finite
Reference:
Share your thoughts in the comments
Please Login to comment...