Reputation: 371
The problem requires me to use 64-bit integer. How can I initialize and implement that in python3?
Upvotes: 10
Views: 26817
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
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