How can I initialize and use 64-bit integer in Python3

16,728

Solution 1

You've misinterpreted their warning. They're telling you to use a larger type than normal in order to avoid overflow issues seen with a 32-bit type. Since Python's int is essentially boundless there will never be an overflow issue.

Solution 2

Frankly, sometimes it is bad to use unlimited integers in Python. Best alternative is to use NumPy fixed length types if you really need exactly 32bit or 64bit ops.

import numpy as np

v = np.uint64(99)
q = np.uint64(12) * v + np.uint64(77)

print(q)
print(type(q))
Share:
16,728

Related videos on Youtube

Ritwik Jamuar
Author by

Ritwik Jamuar

This is Ritwik Jamuar, a fresher, completed his Graduation of BE ( Bachelor of Engineering ) from VTU ( Visvesaraya Technological University ) at CMR Institute of Technology, Bengaluru, is ready to take positions that offers him Mobile Application Development, and has developed his skill in Programming, specifically in languages like Java and Python and right now learning new Languages such as JavaScript for Developing Mobile Applications using React-Native.

Updated on June 04, 2022

Comments

  • Ritwik Jamuar
    Ritwik Jamuar almost 2 years

    The problem requires me to use 64-bit integer. How can I initialize and implement that in python3?