Re: [PHP-DEV] Re: #22527 [Opn->Bgs]: Modulus returned negative value
[email protected] (Rasmus Lerdorf)
| Newsgroups | php.dev |
|---|---|
| Message-ID | <[email protected]> |
On Tue, 4 Mar 2003, Sascha Schumann wrote: > > Well, Perl can lean the other way as well actually. Try this: > > Is there some documentation why the default is as it is? All I could find was this description of the Perl modulus operator: Binary ``%'' computes the modulus of two numbers. Given integer operands $a and $b: If $b is positive, then $a % $b is $a minus the largest multiple of $b that is not greater than $a. If $b is negative, then $a % $b is $a minus the smallest multiple of $b that is not less than $a (i.e. the result will be less than or equal to zero). Note than when use integer is in scope, ``%'' give you direct access to the modulus operator as implemented by your C compiler. This operator is not as well defined for negative operands, but it will execute faster. -Rasmus