Back
I am looking for minimum and maximum values for integers in python. For eg., in Java, we have Integer.MIN_VALUE and Integer.MAX_VALUE. Is there something like this in python?
Python 3 does not have a maximum size of int. The plain int type is unbounded in Python 3.
But you can check machines word size( Word size is a fixed-sized piece of data handled as a unit by the instruction set or the hardware of the processor). That is available in Python 3 which can be seen by running the following code.
import sysSys.maxsize
import sys
Sys.maxsize
But in Python 2, the maximum and minimum value for plain int values is available which can be seen by the following code.
import sysmax= sys.maxintmin= -sys.maxint -1 print(max) print(min)
max= sys.maxint
min= -sys.maxint -1
print(max) print(min)
Python seamlessly switches from plain too long integers once you exceed this value. So most of the time, you won't need to know it.
To know more about this you can have a look at the following video tutorial:-
31k questions
32.8k answers
501 comments
693 users