Ritwik Jamuar
Ritwik Jamuar

Reputation: 371

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

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

Upvotes: 10

Views: 26817

Answers (2)

Severin Pappadeux
Severin Pappadeux

Reputation: 20080

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))

Upvotes: 10

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798566

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.

Upvotes: 18

Related Questions