I've been trying to find out how to represent a maximum integer, and I've read to use
Mazdak 102k17 gold badges156 silver badges181 bronze badges asked Dec 10, 2012 at 5:56
1
http://docs.python.org/3.1/whatsnew/3.0.html#integers
martineau 115k25 gold badges160 silver badges281 bronze badges answered Dec 10, 2012 at 5:58
Diego BaschDiego Basch 12.4k2 gold badges28 silver badges23 bronze badges 2 As pointed out by others, Python 3's Note: as per ely's comment, this may impact the efficiency of your code, so it may not be the best solution. answered Apr 8, 2014 at 21:09
mwfearnleymwfearnley 2,9012 gold badges29 silver badges35 bronze badges 2 If you are looking for a number that is bigger than all others: Method 1:
Method 2:
If you are looking for a number that is smaller than all others: Method 1:
Method 2:
Method 1 works in both Python2 and Python3. Method 2 works in Python3. I have not tried Method 2 in Python2.
chash 3,62710 silver badges27 bronze badges answered Jan 14, 2019 at 0:28
VikrantVikrant 1,05912 silver badges18 bronze badges 4 Python 3 ints do not have a maximum. If your purpose is to determine the maximum size of an int in C when compiled the same way Python was, you can use the struct module to find out:
If you are curious about the internal implementation details of Python 3 int objects, Look at answered Dec 10, 2012 at 6:58
gpsgps 1,24411 silver badges11 bronze badges 1 Python 3.0 doesn't have sys.maxint any more since Python 3's ints are of arbitrary length. Instead of sys.maxint it has sys.maxsize; the maximum size of a positive sized size_t aka Py_ssize_t. answered Dec 28, 2017 at 14:42
An alternative is
answered May 14, 2020 at 20:54
wstomvwstomv 6311 gold badge5 silver badges11 bronze badges Not the answer you're looking for? Browse other questions tagged python python-3.x or ask your own question. |