Integer math question

Sean Ross sross at connectmail.carleton.ca
Sat Jan 3 15:20:01 EST 2004


"Rainer Deyke" <rainerd at eldwood.com> wrote in message
news:kTEJb.724242$HS4.5376202 at attbi_s01...
> Sean Ross wrote:
> > a = bq + r       and  0<=r<b       [1]
>
> But 0 <= r < b is a contradiction when b < 0.
>
> -- 
> Rainer Deyke - rainerd at eldwood.com - http://eldwood.com
>
>

Hmm....

>>> a = 5
>>> b = -10
>>> q,r = divmod(a,b)
>>> q
-1
>>> r
-5
>>>

Here, the division algorithm does not apply (b is a negative integer).
Perhaps there's some other theorem for this case?
b<r<=0, when b < 0? I don't know.






More information about the Python-list mailing list