Is there some pre-defined constant like INT_MAX
?
CARVIEW |
Select Language
HTTP/2 301
date: Sun, 27 Jul 2025 20:29:01 GMT
content-length: 0
location: /questions/4581842/is-there-a-way-to-get-the-largest-integer-one-can-use-in-python
cf-ray: 965ee2effefde084-BLR
cf-cache-status: DYNAMIC
cache-control: private
set-cookie: prov=14aa6e99-6946-4071-8c81-6a4cd986756b; expires=Mon, 27 Jul 2026 20:29:00 GMT; domain=.stackoverflow.com; path=/; secure; httponly
strict-transport-security: max-age=31536000; includeSubDomains
content-security-policy: upgrade-insecure-requests; frame-ancestors 'self' https://stackexchange.com
feature-policy: microphone 'none'; speaker 'none'
x-clacks-overhead: GNU Terry Pratchett
x-frame-options: SAMEORIGIN
x-request-guid: aad3dde3-ae61-4f8c-90f5-f61c5a321199
x-worker-origin-response-time: 251000000
vary: Accept-Encoding
x-dns-prefetch-control: off
set-cookie: __cflb=02DiuFA7zZL3enAQJD3AX8ZzvyzLcaG7wRy8B141kZ3BA; SameSite=Lax; path=/; expires=Mon, 28-Jul-25 19:29:01 GMT; HttpOnly
set-cookie: prov=14aa6e99-6946-4071-8c81-6a4cd986756b; Path=/; HttpOnly; Domain=stackoverflow.com
set-cookie: __cf_bm=lGr.ylwGSGY8OLdHWovUp.McgJH7_IRLZQrRwLFH7cU-1753648141-1.0.1.1-hyEXQlzSlQ1W3.jMDms5uwbocMlOpfn7Irg2ou_pLJs6ZgNNMJIB_vN.biQWj3S4UfYvVnWlIfzWh2QGCWhcQ5PSM7209uRjsme5rD2Kjoc; path=/; expires=Sun, 27-Jul-25 20:59:01 GMT; domain=.stackoverflow.com; HttpOnly; Secure; SameSite=None
set-cookie: _cfuvid=FLQDVKx6FArSSVQ_MFi_semKpj0F8BJYrrWZMzg9POs-1753648141061-0.0.1.1-604800000; path=/; domain=.stackoverflow.com; HttpOnly; Secure; SameSite=None
server: cloudflare
HTTP/2 200
date: Sun, 27 Jul 2025 20:29:01 GMT
content-type: text/html; charset=utf-8
cf-ray: 965ee2f1a8f0e084-BLR
cf-cache-status: DYNAMIC
cache-control: private
set-cookie: prov=14aa6e99-6946-4071-8c81-6a4cd986756b; expires=Mon, 27 Jul 2026 20:29:01 GMT; domain=.stackoverflow.com; path=/; secure; httponly
strict-transport-security: max-age=31536000; includeSubDomains
vary: Accept-Encoding
content-security-policy: upgrade-insecure-requests; frame-ancestors 'self' https://stackexchange.com
feature-policy: microphone 'none'; speaker 'none'
x-clacks-overhead: GNU Terry Pratchett
x-frame-options: SAMEORIGIN
x-request-guid: afce7e26-d642-49f1-854c-a2eab03432d2
x-worker-origin-response-time: 297000000
x-dns-prefetch-control: off
server: cloudflare
content-encoding: gzip
Is there a way to get the largest integer one can use in Python? - Stack Overflow
Skip to main content
Stack Overflow
1
4
- Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers
- Advertising Reach devs & technologists worldwide about your product, service or employer brand
- Knowledge Solutions Data licensing offering for businesses to build and improve AI tools and models
- Labs The future of collective knowledge sharing
- About the company Visit the blog
Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about CollectivesTeams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams-
It is 2^31 - 1 in Python 32 and 2^63 - 1 Python 64 bit runtime system.– Vlad BezdenCommented Feb 11, 2020 at 12:15
Add a comment
|
1 Answer 1
Python has arbitrary precision integers so there is no true fixed maximum. You're only limited by available memory.
In Python 2, there are two types, int
and long
. int
s use a C type, while long
s are arbitrary precision. You can use sys.maxint
to find the maximum int
. But int
s are automatically promoted to long
, so you usually don't need to worry about it:
sys.maxint + 1
works fine and returns a long
.
sys.maxint
does not even exist in Python 3, since int
and long
were unified into a single arbitrary precision int
type.
answered Jan 3, 2011 at 3:14
-
31Note that in Python 3 (and Python 2.6 and up)
sys.maxsize
can be used when you need an arbitrarily-large value.– mattdmCommented Jan 23, 2012 at 19:07 -
1
-
1
sys.maxsize
continues to be the theoretical limit on size of containers for python 2 and 3 (theoretical because memory is the real limiting factor) Commented Mar 11, 2017 at 21:14 -
3
- The Overflow Blog
-
-
- Featured on Meta
-
-
-
-
-
Linked
Related
Hot Network Questions
- Translation of "mode"
- Meaning of 芭蕉 in Tang age
- A word with five hundred of a single alphabet? That must be a myth.
- Are classified documents subject to a subpoena in discovery?
- Mac Pro 2008 almost dead
- Will an error in two of my published papers affect my PhD thesis evaluation?
- Time Machine backup disk not writeable any longer
- How does one justify the rationality of buying insurance?
- How many simple groups are there of a given infinite cardinality?
- Sci-fi book where aliens make contact, ask humans to transport themselves to nearby portal
- What is the citation for Augustine's "consensus, non concubitus..."
- Is this a violation of open source?
- Can Spi flash memory's contents be corrupted from heat?
- Forces applied to a car hood while driving
- Does SZNUD3160 really eliminate the need for diode?
- Measuring position on a system of identical particles
- Symbols for A.P. Morse's book in Set Theory
- How do I set up a recursive algorithm to repeatedly square root a positive real number?
- How to put commutative symbol in a commutative diagram?
- rock paper scissors game with randomized system choices. NOT using rnd()
- how is it possible for a player to have crossed 2400 and secure 3+ IM norms to stay FM
- I don't understand Photos Library.photoslibrary
- Does passive DisplayPort-HDMI adapter work with 4K 60Hz, if host supports DP 1.2 and HDMI 1.4?
- Are you required to protect trade secrets revealed to you even if you didn't sign an NDA?
lang-py