Discussion:
[Numpy-discussion] strange casting rules
Neal Becker
2015-07-29 12:07:08 UTC
Permalink
np.uint64(-1)+0
Out[36]: 1.8446744073709552e+19

I often work on signal processing requiring bit-exact integral arithmetic.
Promoting to float is not helpful - I don't understand the logic of the
above example.
Robert Kern
2015-07-29 12:31:02 UTC
Permalink
Post by Neal Becker
np.uint64(-1)+0
Out[36]: 1.8446744073709552e+19
I often work on signal processing requiring bit-exact integral arithmetic.
Promoting to float is not helpful - I don't understand the logic of the
above example.
See this thread:

http://mail.scipy.org/pipermail/numpy-discussion/2015-July/073196.html

Cast your 0 to a uint64 or other unsigned int type to avoid this.

--
Robert Kern

Loading...