[issue22444] Floor divide should return int

Stefan Krah report at bugs.python.org
Mon Sep 22 21:48:40 CEST 2014


Stefan Krah added the comment:

Alexander Belopolsky <report at bugs.python.org> wrote:
> Raymond suggested that "The PEP 3141 should be revised to say that floor division is defined to return a value that is *equal* to an Integral".

I guess it should say "equal to an Integral or a special value".

> Since nan or inf are not *equal* to any Integral, the current implementation does not comply.  In the absence of a recommendation in the PEP, implementers of new numeric types are left with little guidance because existing types are inconsistent:
> 
> >>> Decimal('inf') // 1
> Decimal('Infinity')
> >>> float('inf') // 1
> nan

I think both should return inf.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22444>
_______________________________________


More information about the Python-bugs-list mailing list