What is python max int?

There is no soft limit for an integer values in Python 3 - plain int is unbounded and limited only by RAM memory size. So you can assume you can store any value and it will work.

What if I need python max int for algorythm implementation?

Some algorythms should assume having a maximum value as a starting point.

For example, finding minimum algorythm might be imlemented by assigning max int value at the beginning and subsequent comparing it to each array value.

For these purpuses you should use a special constant math.inf insted of finding max int python's value.
To use it you should import math module:

import math

And then you can play with comparing math.inf:

As you can see math.inf is greater than every integer in the world, so you can assume it is a "virtual max int"

#python #math
menu 19
Bruce Hardy profile picture
Nov 01, 2020
by Bruce Hardy

Best related

Other by Bruce Hardy