List:General Discussion« Previous MessageNext Message »
From:Thomas Lenherr Date:February 24 2005 11:34pm
Subject:modulo operation
View as plain text  

I just wanted to know if there is a special reason for the 
mathematically incorrect implementation of the modulo-operation in mysql.
Using a correct modulo operation on a negative number would still result 
in a positive number:
-1 % 2 == 1  (mysql: -1)
-5 % 3 == 1  (mysql: -2)
-1 % 4 == 3  (mysql: -1)

(For the exact definition see )

AFAIK most programming languages implement modulo in this wrong way 
(except pascal i think), but I don't have a clou why it should stay that 
way as I find this behaviour rather disturbing...

modulo operationThomas Lenherr25 Feb
  • Re: modulo operationJigal van Hemert25 Feb
    • Re: modulo operationPeter Brawley25 Feb
  • Re: modulo operationJigal van Hemert25 Feb
    • Re: modulo operationThomas Lenherr25 Feb