[Numpy-discussion] Floor divison on int returns float

Antoine Pitrou solipsis at pitrou.net
Thu Apr 14 04:06:28 EDT 2016

On Wed, 13 Apr 2016 15:49:15 -0600
Charles R Harris <charlesr.harris at gmail.com> wrote:
> I looked this up once, `C` returns unsigned in the scalar case when both
> operands have the same width. See Usual Arithmetic Conversions
> <https://www.securecoding.cert.org/confluence/display/c/INT02-C.+Understand+integer+conversion+rules>.
> I think that is not a bad choice, but there is the back compatibility
> problem, plus it is a bit exceptional.

It may be a worse choice for Python. In the original use case (indexing
with an integer), losing the sign is a bug since negative indices have
a well-defined meaning in Python. This is a far more likely issue than
magnitude loss on a 64-bit integer.

In Numba, we decided that combining signed and unsigned would return
signed (see



More information about the NumPy-Discussion mailing list