Double.IsPositiveInfinity() Method in C#
In C#, Double.IsPositiveInfinity() is a Double struct method. This method is used to check whether a specified value evaluates to positive infinity or not. In some floating point operation, it is possible to obtain a result that is positive infinity. For Example: If any positive value is divided by zero, it results in positive infinity.
Syntax: public static bool IsPositiveInfinity (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 specified value evaluates to positive infinity, otherwise return False.
Example:
Input : d = 10 / 0.0
Output : True
Input : d = 7.997e307 + 9.985e307;
Output : True
Code: To demonstrate the Double.IsPositiveInfinity(Double) Method
using System;
class GFG {
static public void Main()
{
double zero = 0.0;
double value = 10.0;
double result = value / zero;
Console.WriteLine(result);
Console.WriteLine(Double.IsPositiveInfinity(result));
result = 7.997e307 + 9.985e307;
Console.WriteLine(result);
Console.WriteLine(Double.IsPositiveInfinity(result));
}
}
|
Note:
- Floating-point operation return Infinity (Positive Infinity) or -Infinity (Negative Infinity) to indicate an overflow condition.
- The result of any floating point operation that exceeds Double.MaxValue (i.e 1.7976931348623157E+308 ) is considered as Positive Infinity.
Last Updated :
13 Feb, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...