Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Python by (19k points)

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?

1 Answer

0 votes
by (106k points)
edited by
  • 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 sys

Sys.maxsize

image

  • But in Python 2, the maximum and minimum value for plain int values is available which can be seen by the following code.

import sys

max= sys.maxint

min= -sys.maxint -1 

print(max) print(min)

image

  • 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:-

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Feb 16, 2021 in Java by sheela_singh (9.5k points)
0 votes
1 answer

Browse Categories

...