Double.IsFinite()方法用于检查double值是否超出范围。
用法: public static bool IsFinite (double value);
返回值:如果值是有限的,则此方法返回true,否则返回false。
下面的程序说明Double.IsFinite()方法的使用:
示例1:
// C# program to demonstrate the
// Double.IsFinite() Method
using System;
using System.Globalization;
class GFG {
// Main Method
public static void Main()
{
// Declaring and initializing value1
double value1 = 10d;
// using IsFinite() method
bool value = Double.IsFinite(value1);
// Displaying the result
if (value)
Console.WriteLine("{0} is finite", value1);
else
Console.WriteLine("{0} is not finite", value1);
}
}
输出:
10 is finite
示例2:
// C# program to demonstrate the
// Double.IsFinite() Method
using System;
using System.Globalization;
class GFG {
// Main Method
public static void Main()
{
// Declaring and initializing value1
double value1 = Math.Pow(2, 1000000000000);
// using IsFinite() method
bool value = Double.IsFinite(value1);
// Displaying the result
if (value)
Console.WriteLine("{0} is finite", value1);
else
Console.WriteLine("{0} is not finite", value1);
}
}
输出:
Infinity is not finite
相关用法
- C# Uri.IsBaseOf(Uri)用法及代码示例
- C# Random.Next()用法及代码示例
- C# Uri.ToString()用法及代码示例
- C# Uri.IsWellFormedOriginalString()用法及代码示例
- C# Uri.GetHashCode()用法及代码示例
- C# Math.Log()用法及代码示例
- C# Uri.FromHex()用法及代码示例
- C# Uri.IsHexDigit()用法及代码示例
- C# Queue.Contains()用法及代码示例
注:本文由纯净天空筛选整理自RohitPrasad3大神的英文原创作品 Double.IsFinite() Method in C#。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。