Re: Re: #22527 [Opn->Bgs]: Modulus returned negative value
| From: | George Schlossnagle | Date: | Tue, 04 Mar 2003 15:41:11 +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-94760@lists.php.net to get a copy of this message | ||
On Tuesday, March 4, 2003, at 10:33 AM, Sascha Schumann wrote:
On Tue, 4 Mar 2003, George Schlossnagle wrote:Yeah, I read that in the bug report and confirmed that as the intended behavior in C. What I meant was 'regardless of what the ISO standard says, thats not a standard mathematical definition.'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.