Re: Re: #22527 [Opn->Bgs]: Modulus returned negative value
| From: | George Schlossnagle | Date: | Tue, 04 Mar 2003 15:18:59 +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-94758@lists.php.net to get a copy of this message | ||
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.
On Tuesday, March 4, 2003, at 02:37 AM, Rasmus Lerdorf wrote:
This is actually an interesting question. Should we be truncating towards zero? I'd say yes, but then I tested Perl, Python and Tcl, and they all say that -27 % 7 is 1 which means they truncate towards negative infinity.