Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Python

math.inf

Represents positive floating-point infinity and can serve as an initial upper bound.

Version: Python 3.14; repository image, production runtime not attested

Syntax

math.inf

Represents positive floating-point infinity and can serve as an initial upper bound.

Negating the constant produces negative infinity. Finite integers do not exceed positive infinity.

Positive infinity exceeds every finite real value, so it exceeds even the large integer in the example. Negating it gives the other signed infinity and isinf recognizes both. NaN is unordered: its less-than comparison with positive infinity is false.

import math
assert -math.inf < -(10**100) < 10**100 < math.inf
assert not (math.nan < math.inf) and math.isinf(-math.inf)

Examples

import math
print(math.inf > 10 ** 100)
print(math.isinf(-math.inf))

Result

True
True

Positive infinity exceeds every finite real value, so it exceeds even the large integer in the example. Negating it gives the other signed infinity and isinf recognizes both. NaN is unordered: its less-than comparison with positive infinity is false.

Sources