본문 바로가기
CS/Python

[Python] 파이썬 자료형 - 숫자형 최대값

by Warehaus 2021. 5. 20.

숫자형 자료형을 보다보니 파이썬에서 숫자를 어디까지 사용 가능한지 궁금해졌다.

>>> import sys
>>> a = sys.maxsize
>>> b = sys.maxsize+1
>>>
>>> a
9223372036854775807
>>> b
9223372036854775808
>>> type(a)
<class 'int'>
>>> type(b)
<class 'int'>

 

Python3 에서는 별도로 long type을 사용하지 않는데, 아무튼 제한 범위가 거의 없다시피 하다.

메모리가 허용하는 한 제한없이 사용 가능하다고 보면 되는데..

다른 언어에서는 구현되지 않은 부분이 어떻게 가능한지 궁금해졌다.  여기저기 좀 찾아봐야겠다.

내용은 아래의 링크를 참고해봤다.

https://note.nkmk.me/en/python-int-max-value/

 

Integers (int) has no maximum limit in Python3 | note.nkmk.me

Python2 has two integer type, int and long, but Python3 has only int.int in Python3 is equivalent to long in Python2, and there is no limit on the maximum value. It is possible to handle as large value as memory is available.This article describes the foll

note.nkmk.me