[Python-Dev] Floor division

Tim Peters tim.peters at gmail.com
Tue Jan 23 08:43:04 CET 2007


[Guido]
>> The ints aren't really embedded in Decimal, so we don't have to do
>> that there (but we could).

[Facundo Batista]
> -0.
>
> If we can't achieve it without disturbing the rest of Python, I'll try
> as much as possible to keep what the Spec proposes.

Which "Spec"?  For example, floor division isn't mentioned at all in
IBM's proposed decimal standard, or in PEP 327, or in the Python
Library Reference section on `decimal`.  It's an artifact of trying to
extend Python's integer mod definition to floats, and for reasons
explained in this thread (for the 27th time ;-)), that definition
doesn't make good sense for floats.  The IBM spec defines `remainder`
and `remainder-near` for floats, and those do make good sense for
floats.  But they're /different/ definitions than Python uses for
integer mod.

Do note that this discussion is only about Python 3.  Under the view
that it was a (minor, but real) design error to /try/ extending
Python's integer mod definition to floats, if __mod__, and __divmod__
and __floordiv__ go away for binary floats in P3K they should
certainly go away for decimal floats in P3K too.  And that's about
syntax, not functionality:  the IBM spec's "remainder" and
"remainder-near" still need to be there, it's "just" that a user would
have to get at "remainder" in a more long-winded way (analogous to
that a P3K user would have to spell out "math.fmod" to get at a mod
function for binary floats).


More information about the Python-Dev mailing list