In Python, you can do:

test = float("inf")

In Python 3.5, you can do:

import math
test = math.inf

And then:

test > 1
test > 10000
test > x

Will always be true. Unless of course, as pointed out, x is also infinity or "nan" ("not a number").

Additionally (Python 2.x ONLY), in a comparison to Ellipsis, float(inf) is lesser, e.g:

float('inf') < Ellipsis

would return true.

Answer from WilHall on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-infinity
Python infinity (inf) - GeeksforGeeks
The float() constructor can create positive and negative infinity.
Published: 1 day ago
Discussions

float('inf') is bad practice
math.inf is there for you, and I prefer it over float('inf') in most if not all cases. More on reddit.com
🌐 r/Python
72
79
April 15, 2024
algorithm - How to implement negative infinity in Python? - Stack Overflow
Python has special values float('inf') and float('-inf'). ... I prefer using the inf constant from the math module (from math import inf). You can then specify -inf for negative infinity. More on stackoverflow.com
🌐 stackoverflow.com
Testing for positive infinity, or negative infinity, individually in Python - Stack Overflow
math.isinf() tests for positive or negative infinity lumped together. What's the pythonic way to test for them distinctly? More on stackoverflow.com
🌐 stackoverflow.com
A value doesn't print()
Therefore you’re looping over the range(False, True) (basically equivalent to range(0, 1)). You’re looping in steps of 1 · Also, item does have a ‘value’, which is changed from the initialize value of 0.0 by the for: loop; it’s just that the above logic does not permit said value ... More on discuss.python.org
🌐 discuss.python.org
19
0
March 8, 2023
🌐
W3Schools
w3schools.com › python › ref_math_inf.asp
Python math.inf Constant
The math.inf constant returns a floating-point positive infinity. For negative infinity, use -math.inf.
🌐
FavTutor
favtutor.com › blogs › infinity-python
Infinity in Python (float('inf'), math.inf) | FavTutor
July 21, 2026 - In Python, infinity is a float value written as float("inf"). It is larger than every other number, and its negative counterpart float("-inf") is smaller than every other number.
🌐
CodeGym
codegym.cc › java blog › learning python › infinity in python: mastering the infinite
Infinity in Python: Mastering the Infinite
August 13, 2024 - import numpy as np positive_infinity_np = np.inf negative_infinity_np = -np.inf print(positive_infinity_np) # Output: inf print(negative_infinity_np) # Output: -inf · Numpy’s infinity behaves similarly to the built-in float infinity but can be more convenient when working with large arrays and matrices. Infinity isn’t just a quirky Python feature—it has practical uses in algorithm design.
Find elsewhere
🌐
Note.nkmk.me
note.nkmk.me › home › python
Infinity (inf) in Python | note.nkmk.me
August 11, 2023 - You can create inf with float('inf'). ... inf print(type(f_inf)) # <class 'float'> ... Negative infinity can be represented by adding - to inf....
🌐
DEV Community
dev.to › hrishikesh1990 › how-to-represent-an-infinite-number-in-python-2fm2
How to represent an infinite number in Python? - DEV Community
April 18, 2022 - Since Infinite numbers are both positive and negative, Therefore, in Python, they can be represented using float(‘inf’) and float(‘-inf’).
🌐
NumPy
numpy.org › devdocs › reference › constants.html
Constants — NumPy v2.6.dev0 Manual
NumPy uses the IEEE Standard for Binary Floating-Point for Arithmetic (IEEE 754). This means that Not a Number is not equivalent to infinity. Also that positive infinity is not equivalent to negative infinity.
🌐
Python.org
discuss.python.org › python help
A value doesn't print() - Python Help - Discussions on Python.org
March 8, 2023 - def infi (): negativeInfi = float("-inf") possitiveInfi = float("inf") Thanks.
🌐
Polo Club of Data Science
poloclub.github.io › transformer-explainer
Transformer Explainer: LLM Transformer Model Visually Explained
Scaling · Mask: The attention scores are scaled and a mask is applied to the upper triangle of the attention matrix to prevent the model from accessing future tokens, setting these values to negative infinity.
🌐
Wikipedia
en.wikipedia.org › wiki › Half-precision_floating-point_format
Half-precision floating-point format - Wikipedia
1 week ago - ARM processors support (via a floating-point control register bit) an "alternative half-precision" format, which does away with the special case for an exponent value of 31 (111112). It is almost identical to the IEEE format, but there is no encoding for infinity or NaNs; instead, an exponent ...
🌐
TutorialsPoint
tutorialspoint.com › article › replace-nan-with-zero-and-fill-negative-infinity-values-in-python
Replace NaN with zero and fill negative infinity values in Python
March 26, 2026 - The numpy.nan_to_num() function is essential for data preprocessing, converting problematic NaN and infinity values into workable numbers.
🌐
Zig
ziglang.org › documentation › master
Documentation - The Zig Programming Language
There is no syntax for NaN, infinity, or negative infinity.
🌐
Medium
koshurai.medium.com › infinity-in-python-156b55ae0c54
Infinity in Python. In Python, the value float("inf")… | by KoshurAI | Medium
December 31, 2022 - In Python, the value float("inf") represents positive infinity, and float("-inf") represents negative infinity.
🌐
Codecademy
codecademy.com › docs › python › math module › math.isinf()
Python | Math Module | math.isinf() | Codecademy
September 4, 2024 - The math.isinf() function in Python checks whether a given value is infinite. It returns True if the value is positive or negative infinity, and False otherwise.
🌐
Reddit
reddit.com › r/programminglanguages › how stupid is the idea of having infinity included in integer type? more over, how to design a integer/floating point system that makes more sense mathematically?
r/ProgrammingLanguages on Reddit: How stupid is the idea of having infinity included in integer type? More over, how to design a integer/floating point system that makes more sense mathematically?
July 26, 2023 -

So in my imagined language, efficiency is not an issue. I decide to use arbitrary precision integers(i.e. big ints). I realize that sometimes you need infinity as a boundary, so I'm curious, how bad is the idea of having positive/negative infinity in integer type?

I know the fact that you have more UBs, like 0*inf doesn't make sense, but it's fundamentally the same as div by 0 problems. And it should be solved the same as div by 0s.

And for floating numbers, we're all plagued by precision problems, so I think it should make sense for any floating number to be encoded by x = (a, b), where it means that: a - b < x < a + b, and as you do floating point arithemetic, b grows and you lose the precision.

In general, is there any efforts on designing a number system for both integer/floating nums that make more sense mathematically, when you don't care about performance?

EDIT: just realized that haskell have both NAN and INF included in the language.