Single.IsNegativeInfinity() Method in C# with Examples
Last Updated :
01 May, 2019
In C#, Single.IsNegativeInfinity(Single) is a Single struct method. This method is used to check whether a specified floating-point value evaluates to negative infinity or not. In some floating point operation, it is possible to obtain a result that is negative infinity. For Example: If any negative value is divided by zero, it results in negative infinity.
Syntax: public static bool IsNegativeInfinity (float f);
Parameter:
f: It is a single-precision floating-point number of type System.Single.
Return Type: This function return a boolean value True, if specified value evaluates to negative infinity, otherwise return False.
Example: To demonstrate the Single.IsNegativeInfinity(Single) Method:
using System;
class GFG {
static public void Main()
{
float zero = 0.0f;
float value = -5f;
float result = value / zero;
Console.WriteLine(result);
Console.WriteLine(Single.IsNegativeInfinity(result));
result = Single.MinValue * 7.9f;
Console.WriteLine(result);
Console.WriteLine(Single.IsNegativeInfinity(result));
}
}
|
Output:
-Infinity
True
-Infinity
True
Note:
- The result of any floating point operation that is less than Single.MinValue is considered as Negative Infinity.
- Floating-point operation return PositiveInfinity or NegativeInfinity to indicate the overflow condition.
Reference:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...