[Python-Dev] Floor division

Armin Rigo arigo at tunes.org
Tue Jan 23 17:03:03 CET 2007


Hi Tim,

On Sun, Jan 21, 2007 at 09:08:18PM -0500, Tim Peters wrote:
> >BTW - isn't that case in contradiction with the general Python rule that
> >if b > 0, then a % b should return a number between 0 included and b
> >excluded?
> 
> Sure.

You're not addressing my point, though, so I was probably not clear
enough.  My surprize was not that a % b was equal to b in this case, and
so not strictly smaller than b (because I expect such things when
working with floats).  My surprize was that Decimals don't even try to
be between 0 and b, and sometimes give a result that is far outside the
range.  This surprized me because I expected floats and Decimals to try
to give "approximately equal" results...


A bientot,

Armin


More information about the Python-Dev mailing list