Why the answer is floating point? I thought it should be an integer.
>>> import numpy as np
>>> np.uint64(12)
12
>>> np.uint64(12) + int(4)
16.0
>>>
Based on a recent reddit post.
This is the way Numpy functions are designed to return consistent values for the whole range of input data.
Both 16-bit unsigned and signed integers would fit into int32, therefore
>>> np.uint16(4) + np.int16(5)
9
However for uint64 and int64 the smallest datatype that would fit all possible values is float64.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With