How Big Is an int?python
In Python2, the size of an int
was limited to 32 bits, which is enough to store an integer from -2,147,483,648 to 2,147,483,647. A long
can store 64 bits. Integers larger than the range will cause Integer Overflow.ide
In case you wonder where does this range come from. Computers store numbers in its binary format, 32 bits means we have 32 binary bits to store a number. That's why we can only store 232232 different integers. Since we want to store both positive numbers and negative numbers at the same time, each side will get 231231 numbers, which is 2,147,483,648.測試
In Python3, an int
can handle any integer no matter how large it is without causing overflow.this
Python3中整形能夠用任意大小,不會出現溢出狀況。spa
jupyter notebook中測試以下:3d
The strings is a sequence of characters. strings是character組成的序列。code