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

[email protected] (George Schlossnagle)
Newsgroups php.dev
Message-ID <[email protected]>
On Tuesday, March 4, 2003, at 10:33  AM, Sascha Schumann wrote:

> 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.

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.'
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.