np.isfinite
Python math.isfinite()方法 (Python math.isfinite() method)
math.isfinite() method is a library method of math module, it is used to check whether a given number is a finite number of not, it accepts a number (integer/float, finite, infinite or NaN), and returns True if number neither an infinity nor a NaN (Not A Number), else it returns False.
math.isfinite()方法是数学模块的库方法,用于检查给定数是否为not的有限数,它接受数字(整数/浮点数,有限,无限或NaN),如果满足,则返回True既不是无穷大也不是NaN(不是数字),否则返回False 。
Syntax of math.isfinite() method:
math.isfinite()方法的语法:
math.isfinite(n)
Parameter(s): n – a number that has to be checked whether it is finite or not.
参数: n –一个必须检查其是否有限的数字。
Return value: bool – it returns a Boolean ("True" or "False") value.
返回值: bool –返回布尔值(“ True”或“ False”)。
Example:
例:
Input:
a = 10
b = float('inf')
# function call
print(math.isfinite(a))
print(math.isfinite(b))
Output:
True
False
Python代码演示math.isfinite()方法的示例 (Python code to demonstrate example of math.isfinite() method)
# python code to demonstrate example of
# math.isfinite() method
# importing math module
import math
# math.isfinite() method test on finite value
print(math.isfinite(10))
print(math.isfinite(0))
print(math.isfinite(10.23))
print(math.isfinite(0.0))
# math.isfinite() method test on infinite value
print(math.isfinite(float('inf')))
print(math.isfinite(float('-inf')))
print(math.isfinite(float('nan')))
Output
输出量
True
True
True
True
False
False
False
Recommended posts
推荐的帖子
math.isinf() method with example in Python
带有Python示例的math.isinf()方法
math.isnan() method with example in Python
带有Python示例的math.isnan()方法
math.remainder() method with example in Python
带有Python示例的math.remainder()方法
math.ceil() method with example in Python
Python中带有示例的math.ceil()方法
math.floor() method with example in Python
带有Python示例的math.floor()方法
math.exp() method with example in Python
带有Python示例的math.exp()方法
math.fabs() method with example in Python
带有Python示例的math.fabs()方法
math.fmod() method with example in Python
带有Python示例的math.fmod()方法
math.modf() method with example in Python
带有Python示例的math.modf()方法
math.fsum() method with example in Python
带有Python示例的math.fsum()方法
abs() vs fabs() methods in Python
Python中的abs()vs fabs()方法
math.gcd() method with example in Python
带有Python示例的math.gcd()方法
math.pow() method with example in Python
带有Python示例的math.pow()方法
math.sqrt() method with example in Python
带有Python示例的math.sqrt()方法
math.factorial() method with example in Python
带有Python示例的math.factorial()方法
翻译自: https://www.includehelp.com/python/math-isfinite-method-with-example.aspx
np.isfinite