You are right that an integer infinity is possible, and that none has been added to the Python standard. This is probably because math.inf supplants it in almost all cases (as Martijn stated in his comment).

In the meantime, I added an implementation of extended integers on PyPI:

In [0]: from numbers import Integral, Real

In [0]: from extended_int import int_inf, ExtendedIntegral, Infinite

In [0]: i = int_inf

In [4]: float(i)
Out[4]: inf

In [5]: print(i)
inf

In [6]: i ** i

Out[6]: inf

In [7]: i
Out[7]: inf

In [9]: isinstance(i, Real)

Out[9]: True

In [10]: isinstance(i, Integral)

Out[10]: False

In [11]: isinstance(i, Infinite)

Out[11]: True

In [12]: isinstance(i, ExtendedIntegral)

Out[12]: True

In [13]: isinstance(2, ExtendedIntegral)

Out[13]: True

In [14]: isinstance(2, Infinite)

Out[14]: False
Answer from Neil G on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-infinity
Python infinity (inf) - GeeksforGeeks
Pythons math.inf constant return positive infinity and -math.inf returns negative infinity.
Published   July 12, 2025
Discussions

algorithm - How to implement negative infinity in Python? - Stack Overflow
I prefer using the inf constant from the math module (from math import inf). You can then specify -inf for negative infinity. 2021-11-21T20:33:56.107Z+00:00 ... Save this answer. ... Show activity on this post. As it happens, in Python 2, None is less than any integer, so you can use None. More on stackoverflow.com
🌐 stackoverflow.com
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
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
How to represent infinity in a programming language?
This behavior is described by IEEE standard 754 for floating point arithmetic, and it is implemented in your CPU and GPU hardware. Most other languages (C/C++, Java, JavaScript, etc.) use it as provided, just like Rust does. In IEEE floating point, +/- infinity is represented by a floating point value with the largest possible exponent (all 1's) and a zero mantissa. The sign bit determines whether it is a positive or negative infinity. This specific behavior is actually one of the more reasonable (and even useful) edge cases along those lines in IEEE 754. However, in general, the big selling point is that you don't need to test or throw exceptions until it is convenient: you can run big number crunching loops, then check at intervals to see if your computation has gone off the rails. In many cases, if you want floating point division-by-zero (or similar events) to throw an interrupt, you can set some flags in your floating point control registers to generate that behavior instead. More on reddit.com
🌐 r/ProgrammingLanguages
24
40
April 6, 2022
🌐
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.

🌐
W3Schools
w3schools.com › python › ref_math_inf.asp
Python math.inf Constant
For negative infinity, use -math.inf. The inf constant is equivalent to float('inf'). ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com · If you want to report ...
🌐
Flexiple
flexiple.com › python › python-infinity
Python Infinity - All you need to know | Flexiple Tutorials - Flexiple
March 14, 2022 - According to this standard, a ... 0. Additionally, if the sign bit is 0, it is positive infinity, while a 1 in the sign bit denotes a negative infinity....
🌐
CodeGym
codegym.cc › java blog › learning python › infinity in python: mastering the infinite
Infinity in Python: Mastering the Infinite
August 13, 2024 - This is more of a workaround than a direct method, but it can be quite effective when you need an integer representation of infinity. If you’re not a fan of using float('inf'), Python gives you a few other options. For instance, you can use the decimal module to represent infinity with greater precision: from decimal import Decimal positive_infinity_decimal = Decimal('Infinity') negative_infinity_decimal = Decimal('-Infinity') print(positive_infinity_decimal) # Output: Infinity print(negative_infinity_decimal) # Output: -Infinity
Find elsewhere
🌐
YouTube
youtube.com › shorts › gXUPFf51MG0
Python - How to Represent Infinity - YouTube
#Python #ShortsIf you ever find a need to represent infinity or negative infinity in Python, all you gotta do is pass "inf" or "-inf" string into float, and ...
Published   May 26, 2021
🌐
Note.nkmk.me
note.nkmk.me › home › python
Infinity (inf) in Python | note.nkmk.me
August 11, 2023 - Negative infinity can be represented by adding - to inf. f_inf_minus = -float('inf') print(f_inf_minus) # -inf print(type(f_inf_minus)) # <class 'float'> ... While a float value can typically be converted to int using int(), inf is an exception ...
🌐
TutorialsPoint
tutorialspoint.com › how-can-i-represent-an-infinite-number-in-python
How can I represent an infinite number in Python?
November 9, 2022 - As a result, we cannot represent ... integer. However, float (inf) can be used as an integer. ... Because infinity can be both positive and negative, it can be expressed as a float('inf') and a float('-inf') respective...
🌐
FavTutor
favtutor.com › blogs › infinity-python
Infinity in Python: How to Represent with Inf? (with Examples)
April 3, 2023 - For a wide range of uses, Python includes built-in support for infinity, both positive and negative. float('inf') indicates positive infinity, whereas float('-inf') indicates negative infinity.
🌐
Medium
alysialfi.medium.com › python-float-inf-js-number-negative-infinity-5e4350e84b94
Python float(‘-inf’) & JS Number.NEGATIVE_INFINITY | by Alysia Alfi | Medium
June 10, 2025 - It’s helpful to understand that float('-inf') and Number.NEGATIVE_INFINITY aren't just arbitrary features of Python and JavaScript. They are practical implementations of a universal standard called IEEE 754. This standard defines how computers should handle floating-point arithmetic, and it includes special values to manage mathematical exceptions.
🌐
Codedamn
codedamn.com › news › python › how-to-represent-infinity-in-python
How to Represent Infinity in Python
June 30, 2023 - Codedamn is sunsetting. Learn more about what this means for you.
🌐
Python
docs.python.org › 3 › library › math.html
math — Mathematical functions
Return True if x is neither an infinity nor a NaN, and False otherwise. (Note that 0.0 is considered finite.) Added in version 3.2. ... Return True if x is a positive or negative infinity, and False otherwise.
🌐
iO Flood
ioflood.com › blog › python-infinity
Python Infinity: Syntax, Uses, and Examples
February 12, 2024 - Python, like many programming ... You can create positive and negative infinity in Python using float('inf') and float('-inf'), respectively....
🌐
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.
🌐
Finxter
blog.finxter.com › home › learn python blog › python infinity
Python Infinity - Be on the Right Side of Change
September 16, 2020 - Summary: Python Infinity is an undefined value (negative or positive) such that positive infinity is greater than while negative infinity is lesser than any other value in a given code.
🌐
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.
🌐
Python Central
pythoncentral.io › infinity-in-python-how-to-represent-and-use-infinite-numbers
Infinity In Python: How to Represent (And Use!) Infinite Numbers | Python Central
June 27, 2023 - You can use the attributes math.inf and -math.inf to denote positive and negative infinity, respectively. However, you can only use the math module to represent infinity if you're using Python 3.5 or above.