np.isinf
Python math.isinf()方法 (Python math.isinf() method)
math.isinf() method is a library method of math module, it is used to check whether a number is an infinity (positive or negative), it accepts a number and returns True if the given number is positive or negative infinity, else it returns False.
math.isinf()方法是math模块的库方法,用于检查数字是否为无穷大(正数或负数),它接受数字,如果给定数字为正无穷大或负无穷大,则返回True。返回False 。
Syntax of math.isinf() method:
math.isinf()方法的语法:
math.isinf(n)
Parameter(s): n – a number that has to be checked whether it is infinity 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.isinf(a))
print(math.isinf(b))
Output:
False
True
Python代码演示math.isinf()方法的示例 (Python code to demonstrate example of math.isinf() method)
# python code to demonstrate example of
# math.isinf() method
# importing math module
import math
# math.isinf() method test on finite value
print(math.isinf(10))
print(math.isinf(0))
print(math.isinf(10.23))
print(math.isinf(0.0))
# math.isinf() method test on infinite value
print(math.isinf(float('inf')))
print(math.isinf(float('-inf')))
print(math.isinf(float('nan')))
Output
输出量
False
False
False
True
True
False
Recommended posts
推荐的帖子
翻译自: https://www.includehelp.com/python/math-isinf-method-with-example.aspx
np.isinf