0 votes
1 view
in Python by (15.7k 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 (107k 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
+2 votes
2 answers
asked May 28, 2019 in Python by Ankita (170 points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...