Double.IsNegativeInfinity() Method in C#
Last Updated :
23 Aug, 2021
In C#, Double.IsNegativeInfinity() is a Double struct method. This method is used to check whether a specified 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 (double d);
Parameter:
d: It is a double-precision floating-point number of type System.Double.
Return Type: This function return a Boolean value True, if the specified value evaluates to negative infinity, otherwise return False.
Example:
Input : d = -5.0 / 0.0
Output : True
Input : d = -1.5935e250 * 7.948e110
Output : True
Code: To demonstrate the Double.IsNegativeInfinity(Double) Method
C#
using System;
class GFG {
static public void Main()
{
double zero = 0.0;
double value = -5;
double result = value / zero;
Console.WriteLine(result);
Console.WriteLine(Double.IsNegativeInfinity(result));
result = Double.MinValue * 7.948e110;
Console.WriteLine(result);
Console.WriteLine(Double.IsNegativeInfinity(result));
}
}
|
Output:
-Infinity
True
-Infinity
True
Note:
- The result of any floating point operation is less than Double.MinValue (i.e -1.7976931348623157E+308 ) is considered as Negative Infinity.
- Floating-point operation return Infinity (Positive Infinity) or -Infinity (Negative Infinity) to indicate an overflow condition.
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...