The Double.PositiveInfinity
field is a field in C# that represents positive infinity. It is constant. One way to get the value of this constant is by dividing a positive number by zero.
public const double PositiveInfinity = Infinity;
None.
This returns positive infinity value (Infinity).
// use Systemusing System;// create classclass DoublePositiveInfinity{// main methodstatic void Main(){// print field valueConsole.WriteLine(Double.PositiveInfinity);// check if positive infinityif(-23/0.0 == Double.PositiveInfinity){Console.WriteLine("Positive Infinity");}else{Console.WriteLine("Not Positive Infinity");}// check if positive infinityif(23/0.0 == Double.PositiveInfinity){Console.WriteLine("Positive Infinity");}else{Console.WriteLine("Not Positive Infinity");}}}
Line 10: We print the value of the field Double.PositiveInfinity
.
Line 13–24: We check if -23/0.0
23/0.0
are positive infinity and print the results.