[Numpy-discussion] Rationale for integer promotion rules

Antoine Pitrou solipsis at pitrou.net
Thu Jul 16 12:18:17 EDT 2015


Hi,

We were discussion integer promotion rules amongst the Numba team, and
we were wondering about the rationale for Numpy's rules.  For example,
adding int8 and int8 will give int8 as result (with potential
magnitude loss), while adding int8 and uint8 will give int16 as result
(promoting to the smallest fitting type).  Furthermore, adding int64
and uint64 returns float64.

Is there a rationale somewhere documenting and explaining this behaviour
(sorry if I've missed it in a obvious location)? Is it the produce of
organic evolution?

Also, it is set to stay like this, or will it evolve in the future?

Thank you

Antoine.





More information about the NumPy-Discussion mailing list