Jef*_*f L 33
使用PositiveInfinity和NegativeInfinity常量:
double positive = double.PositiveInfinity;
double negative = double.NegativeInfinity;
Run Code Online (Sandbox Code Playgroud)
Jai*_*han 32
double.PositiveInfinity
double.NegativeInfinity
float zero = 0;
float positive = 1 / zero;
Console.WriteLine(positive); // Outputs "Infinity"
float negative = -1 / zero;
Console.WriteLine(negative); // Outputs "-Infinity"
Run Code Online (Sandbox Code Playgroud)
public const double NegativeInfinity = -1.0 / 0.0;
public const double PositiveInfinity = 1.0 / 0.0;
Run Code Online (Sandbox Code Playgroud)