Método Python math.isinf()
Exemplo
Verifique se um valor é infinito ou não:
# 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))
Definição e uso
O math.isinf()
método verifica se um número é infinito ou não.
Esse método retornará True se o número especificado for um infinito positivo ou negativo, caso contrário, retornará False.
Sintaxe
math.isinf(x)
Valores de parâmetro
Parameter | Description |
---|---|
x | Required. The number to check |
Detalhes técnicos
Valor de retorno: | Um bool valor, True se x for um infinito positivo ou negativo, False caso contrário |
---|---|
Versão do Python: | 2.6 |