-
-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Closed
Labels
15 - Discussion57 - Close?Issues which may be closable unless discussion continuedIssues which may be closable unless discussion continued
Description
Describe the issue:
Dividing (e.g.) (2**64-1) // 3 works as expected if 3 is an int, but produces a float result if 3 is a numpy.int64.
Consequently, the corresponding modulus calculation produces an incorrect result (also float).
This seems to occur just for dividends in the range of 2**63
to 2**64
.
Division of int by numpy.int64 should return the correct integer result for the full range of dividend values.
Reproduce the code example:
import numpy
py3 = 3
npy3 = numpy.int64(3)
n1 = 2**64-1
n2 = 2**63+1
n3 = 2**64+2
n4 = 2**63-2
n5 = 2**128-1
n6 = 2**128+2
print(f"n1 // py3 = {n1 // py3}, n1 % py3 = {n1 % py3}, n1 // npy3 = {n1 // npy3}, n1 % npy3 = {n1 % npy3}")
print(f"n2 // py3 = {n2 // py3}, n2 % py3 = {n2 % py3}, n2 // npy3 = {n2 // npy3}, n2 % npy3 = {n2 % npy3}")
print(f"n3 // py3 = {n3 // py3}, n3 % py3 = {n3 % py3}, n3 // npy3 = {n3 // npy3}, n3 % npy3 = {n3 % npy3}")
print(f"n4 // py3 = {n4 // py3}, n4 % py3 = {n4 % py3}, n4 // npy3 = {n4 // npy3}, n4 % npy3 = {n4 % npy3}")
print(f"n5 // py3 = {n5 // py3}, n5 % py3 = {n5 % py3}, n5 // npy3 = {n5 // npy3}, n5 % npy3 = {n5 % npy3}")
print(f"n6 // py3 = {n6 // py3}, n6 % py3 = {n6 % py3}, n6 // npy3 = {n6 // npy3}, n6 % npy3 = {n6 % npy3}")
Error message:
No response
NumPy/Python version information:
1.23.4 3.10.8 (tags/v3.10.8:aaaf517, Oct 11 2022, 16:50:30) [MSC v.1933 64 bit (AMD64)]
Context for the issue:
No response
Metadata
Metadata
Assignees
Labels
15 - Discussion57 - Close?Issues which may be closable unless discussion continuedIssues which may be closable unless discussion continued