Reference · Math

math.isinf

signature
math.isinf(num) -> bool

What it does

Whether a number is positive or negative infinity, as Python's math.isinf. An int is never infinite. A float becomes infinite when arithmetic runs past the largest float, or when it is made so with float("inf").

Examples

print(math.isinf(float("inf")), math.isinf(float("-inf")), math.isinf(1))print(math.isinf(1e308 * 10), 1e308 * 10)
output
true true falsetrue inf

Edge cases

print(math.isinf(float("nan")), math.isinf(1.8e308), math.isinf(1e309))
output
false true true

Errors

An argument that is not a number is a runtime error, not an error value.

this one fails
print(math.isinf("inf"))
output
line 1: `math.isinf` expects a number as argument 1, got str

Chaining

In a pipeline the number comes first:

print(1e308 * 10 | math.isinf)print([1.0, float("inf"), 3.0] | map(math.isinf))
output
true[false, true, false]

See also

math.isfinite, math.isnan, float

Thread
10Useful? Like it, or add to its thread below.

Thread 0 posts

On math.isinf(): questions, tips, corrections, and code that uses it.

No posts yet. The first one opens the thread.

    Edit this page on GitHub · every example's output was made by running it (tools/refcheck.mjs) · questions on Discord or r/quillo