[Numpy-discussion] Rationale for integer promotion rules

Robert Kern robert.kern at gmail.com
Thu Jul 16 14:19:58 EDT 2015

On Thu, Jul 16, 2015 at 7:14 PM, Nathaniel Smith <njs at pobox.com> wrote:
> On Thu, Jul 16, 2015 at 9:18 AM, Antoine Pitrou <solipsis at pitrou.net>

> > while adding int8 and uint8 will give int16 as result
> > (promoting to the smallest fitting type).
> I understand this to be a consequence of the previous rule (results
> should match inputs) combined with the need to find a common input
> type.

Specifically, when combining signed and unsigned ints, we need to find a
signed int type that can simultaneously hold both of the *inputs*. Whether
the *output* would fit or overflow is not what the rules are concerned with.

Robert Kern
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20150716/bad3b5f9/attachment.html>

More information about the NumPy-Discussion mailing list