[Python-Dev] Floor division

Facundo Batista facundo at taniquetil.com.ar
Tue Jan 23 14:39:02 CET 2007


Tim Peters wrote:

> 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

Oops, you're right. My fault, sorry.


> 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.

I knew the definition of IBM, but assumed (inmersed in my ignorance)
that "remainder" was the way that standard float worked for __mod__. Now
I know that it's not like that, :)


> 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

We'll have to deprecate that functionality, with proper warnings (take
not I'm not following the thread that discuss the migration path to 3k).

And we'll have to add the method "remainder" to decimal objects (right
now we have only "remainder_near" in decimal objects, and both
"remainder" and "remainder_near" in context).

Regards,

-- 
.   Facundo
.
Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/




More information about the Python-Dev mailing list