bug in modulus?

Andrew Koenig ark at acm.org
Tue May 2 17:44:50 CEST 2006

"Andrew Koenig" <ark at acm.org> wrote in message 
news:j3L5g.18187$Fs1.621 at bgtnsc05-news.ops.worldnet.att.net...

> I disagree.  For any two floating-point numbers a and b, with b != 0, it 
> is always possible to represent the exact value of a mod b as a 
> floating-point number--at least on every floating-point system I have ever 
> encountered. The implementation is not even that difficult.

Oops... This statement is true for the Fortran definition of modulus (result 
has the sign of the dividend) but not the Python definition (result has the 
sign of the divisor).  In the Python world, it's true only when the dividend 
and divisor have the same sign.

More information about the Python-list mailing list