On 19/05/2009 9:57 PM, Igor Tandetnik wrote:
> "John Machin" <sjmac...@lexicon.net> wrote
> in message news:4a129cb4.2090...@lexicon.net
>> It's handy for checking how things work e.g.
>>
>> sqlite> select (-1) % 7;
>> -1
>> sqlite> -- it's not a real modulo operator :-(
> 
> What do you feel is wrong with this result? What should a "real" modulo 
> operator return, in your opinion? Before you answer, note that you very 
> likely want this equality to hold for all a, b!=0 :
> 
> a = q*b + r
> where q = a/b, r = a%b

Sure do. No problem for Python:

 >>> for a in (1, -1):
...     for b in (7, -7):
...         q = a / b
...         r = a % b
...         x = b * q + r
...         print a, b, q, r, x
...
1 7 0 1 1
1 -7 -1 -6 1
-1 7 -1 6 -1
-1 -7 0 -1 -1
 >>>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to