On 01/26/2018 08:33 PM, mohammedfaraz...@gmail.com wrote:
import numpy as np x=np.unit8([250) print(x) y=np.unit8([10]) print(y) z=x+y print(z) output [250] [10] [4] My question how is z [4]
Despite all the typos in your post, you appear to be doing 8 bit unsigned arithmetic. Do you know what that means? The answer you might have expected (i.e. 260) does not fit in the 0 ... 255 range of 8 bits, and so the result has overflowed and "wrapped around" to produce 4.
Try this for a simpler example of the same: >>> np.uint8(260) 4 Gary Herron -- Dr. Gary Herron Professor of Computer Science DigiPen Institute of Technology (425) 895-4418 -- https://mail.python.org/mailman/listinfo/python-list