Python math.isinf()メソッド
例
値が無限大かどうかを確認します。
# Import math Library
import math
# Check whether the values are
infinite or not
print(math.isinf(56))
print(math.isinf(-45.34))
print(math.isinf(+45.34))
print(math.isinf(math.inf))
print(math.isinf(float("nan")))
print(math.isinf(float("inf")))
print(math.isinf(float("-inf")))
print(math.isinf(-math.inf))
定義と使用法
このmath.isinf()
メソッドは、数値が無限であるかどうかをチェックします。
このメソッドは、指定された数値が正または負の無限大の場合はTrueを返し、それ以外の場合はFalseを返します。
構文
math.isinf(x)
パラメータ値
Parameter | Description |
---|---|
x | Required. The number to check |
技術的な詳細
戻り値: | bool 値、xが正または負の無限大の場合はTrue、それ以外の場合はFalse |
---|---|
Pythonバージョン: | 2.62.6 |