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.

Syntax:
math.isinf(x)
copy

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

ExampleEdit & Run
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))
copy
Output:
True True True True True [Finished in 0.010723259299993515s]
ExampleEdit & Run
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))
copy
Output:
False False False False False [Finished in 0.011201863177120686s]