The math.isinf() function checks whether a given argument is an infinity. In computing, infinity usually refers to an infinitely large number or an unbounded limit. It is often used to represent values that are too large or too small to be conveniently represented in a finite number.

In Python,  Infinity is represented as  float("inf") and float("-inf") in the case of negative infinity. The math.isinf() returns True if the given argument has this value, else False.

math.isinf(x)

Where is the number which we want to check whether it has a value of infinity.

import math

print(math.isinf(float('inf')))
print(math.isinf(float("-inf")))
print(math.isinf(math.inf))
print(math.isinf(-math.inf))
print(math.isinf(float('inf') + 1000))
import math

print(math.isinf(0))
print(math.isinf(1000000))
print(math.isinf(-0.00000001))
print(math.isinf(math.e))
print(math.isinf(math.pi))