Python - Integer Precision between Python 3.X and Python 2.X

Introduction

Python 3.X integers support unlimited size:

>>> 999999999999999999999999999999 + 1         # 3.X 
1000000000000000000000000000000 

Python 2.X has a separate type for long integers.

It automatically converts any number too large to store in a normal integer to this type.

You don't need to code any special syntax to use longs.

Python 2.X longs is printed with a trailing "L":

>>> 999999999999999999999999999999 + 1         # 2.X 
1000000000000000000000000000000L 

>>> 2 ** 200 
1606938044258990275541962092341162602522202993782792835301376 

>>> 2 ** 200 # 2.X 
1606938044258990275541962092341162602522202993782792835301376L 

Related Topic