Re: Re: #22527 [Opn->Bgs]: Modulus returned negative value

From: Date: Tue, 04 Mar 2003 15:33:29 +0000
Subject: Re: Re: #22527 [Opn->Bgs]: Modulus returned negative value
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-94759@lists.php.net to get a copy of this message
On Tue, 4 Mar 2003, George Schlossnagle wrote: > Interesting. > > I don't know what the ISO standard say, but mathematically a a % b will > always return you an integer 0 <= a%b < b (since there are no negative > numbers in canonical representation of Z/bZ). I guess perl/python/tcl > ddecided to adhere to the mathematical definition. ISO C truncates towards zero. It specifically says in 6.5.5 Multiplicative Operators: If the quotient a/b is representable, the expression (a/b)*b + a%b shall equal a. So -27 % 7 yields -6. - Sascha

« previous php.dev (#94759) next »