+ 3

[✅SOLVED✅] How does Python 3 store huge numbers?

In Python 3, it's possible to have insanely huge numbers, much larger than a C unsigned long long it's maximum size. How exactly is this possible? I have a feeling my basic understanding of how longs and other data types are stored is flawed. Example: https://code.sololearn.com/cCGhSHxtqm4v/?ref=app

15th Dec 2017, 3:13 AM
LunarCoffee
LunarCoffee - avatar
1 Réponse
+ 5
Because Python 3 is High-Level Programming Language. Python supports a "bignum" integer type which can work with arbitrarily large numbers. In Python 2.5+, this type is called long and is separate from the inttype, but the interpreter will automatically use whichever is more appropriate. In Python 3.0+, the int type has been dropped completely. That's just an implementation detail, though — as long as you have version 2.5 or better, just perform standard math operations and any number which exceeds the boundaries of 32-bit math will be automatically (and transparently) converted to a bignum.
15th Dec 2017, 5:43 AM
Kadam Dharmeshbhai Darji
Kadam Dharmeshbhai Darji - avatar