Re: Re: #22527 [Opn->Bgs]: Modulus returned negative value
| From: | Rasmus Lerdorf | Date: | Tue, 04 Mar 2003 18:04:31 +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-94773@lists.php.net to get a copy of this message | ||
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