np.isinf_带有Python示例的math.isinf()方法

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值