I have learned C before, now I am learning Python 3.5, the picture below is from Liao Xuefeng’s website
Why do Python integers and floating point numbers have no size limit? ? How are integers and floating point numbers stored in Python?
Does it mean that all declared integers and floating-point numbers in Python are directly equivalent to long long and long double in C, and are directly allocated to the maximum memory?
phpcn_u15822017-05-18 10:59:58
Python's integers can theoretically be of any length (far beyond long long) as long as the memory can fit.
If C’s long can fit, use long. If it cannot fit, it will automatically convert to a large integer. This process is basically transparent to programmers.
Floating point numbers should be the double type of C.
Floating point numbers are usually implemented using double in C. ——Python official documentation
PHPz2017-05-18 10:59:58
In Python, the length of an integer is unlimited as long as there is enough memory. It should be much larger than long long in C.
Floating point numbers use double precision (64 bit) on the machine, providing about 17 significant digits, which should be similar to the double type in C.