[Python-Dev] Floor division
Nick Maclaren
nmm1 at cus.cam.ac.uk
Thu Jan 25 11:24:38 CET 2007
Armin Rigo <arigo at tunes.org> wrote:
>
> Thanks for the clarification. Yes, it makes sense that __mod__,
> __divmod__ and __floordiv__ on float and decimal would eventually follow
> the same path as for complex (where they make even less sense and
> already raise a DeprecationWarning).
Yes. Though them not doing so would also make sense. The difference
is that they make no mathematical sense for complex, but the problems
with float are caused by floating-point (and do not occur for the
mathematical reals).
There is an argument for saying that divmod should return a long
quotient and a float remainder, which is what C99 has specified for
remquo (except that it requires only the last 3 bits of the quotient
for reasons that completely baffle me). Linux misimplemented that
the last time I looked.
Personally, I think that it is bonkers, as it is fiendishly expensive
compared to its usefulness - especially with Decimal! But it isn't
obviously WRONG.
Regards,
Nick Maclaren,
University of Cambridge Computing Service,
New Museums Site, Pembroke Street, Cambridge CB2 3QH, England.
Email: nmm1 at cam.ac.uk
Tel.: +44 1223 334761 Fax: +44 1223 334679
More information about the Python-Dev
mailing list