Closed c2j closed 1 year ago
CPython does support this, but Numba supports max. 64 bit integers.
from numba import njit # numba==0.57.1 Python 3.8.3 in Linux
import numba as nb
def lucas_lehmer_check_Mersenne(n):
p = n
s = 4
m = 2**p - 1
for _ in range(p-2):
if s**2 > (2**64-1):
print("Overflow! Can't work in Numba with uint64.")
s = (s**2 - 2) % m
return s == 0
print(lucas_lehmer_check_Mersenne(64))
@c2j thank you for submitting this! @max9111 thank you for triaging this. I have labeled this as a feature request for arbitrary precision arithmetic and updated the issue title accordingly.
Thanks for looking at this @max9111 @esc, I think this is a duplicate of #5005 which is asking for "big integer" support, closing as a duplicate.
@c2j thank you for submitting this! @max9111 thank you for triaging this. I have labeled this as a feature request for arbitrary precision arithmetic and updated the issue title accordingly.
If numba is not support big int, WHY there is no throw an ERROR?
Numba compiles functions based on the types of the arguments presented to the function and a lot of "rules" about various operations, it does not check whether the values presented to it at runtime will overflow those types. It's a bit like e.g. C language in this respect. The cost of doing an e.g. overflow check on every operation would massively impact the ability to do things like vectorize loops as there would be so many branches present. With NumPy's NEP-50 proposal it's possible that Numba will gain overflow checking as a mode of operation but the details are not worked out yet.
Reporting a bug
Same program segment wrap jit or not, but different result.