Here's a short C program and results to illustrate my point. It's rather verbose just to be completely explicit. I guess there would be some discussion on converting values like 0x80000000, which would typically be negative in a signed integer, since PHP doesn't support unsigned integers. Should we take the lowest 31 bits and ignore the sign bit or take the full lowest 32 bits, giving the overflow/wrap that some users have been expecting?
======
#include <stdio.h> #include <stdlib.h>
int main() { long long int big1 = 0x100000000LL; long long int big2 = 0x100000001LL; long long int big3 = 0x7FFFFFFFLL; long long int big4 = 0x80000000LL; long mask = 0x7FFFFFFF; long small1 = (long) big1; long small2 = (long) big2; long small3 = (long) big3; long small4 = (long) big4;
printf("big1: %lld\n", big1); printf("big2: %lld\n", big2); printf("big3: %lld\n", big3); printf("big4: %lld\n", big4); printf("mask: %ld\n", mask); printf("small1: %ld\n", small1); printf("small2: %ld\n", small2); printf("small3: %ld\n", small3); printf("small4: %ld\n", small4); printf("----\n"); printf("small1 & mask: %ld\n", small1 & mask); printf("small2 & mask: %ld\n", small2 & mask); printf("small3 & mask: %ld\n", small3 & mask); printf("small4 & mask: %ld\n", small4 & mask);
return 0; }
======
big1: 4294967296 big2: 4294967297 big3: 2147483647 big4: 2147483648 mask: 2147483647 small1: 0 small2: 1 small3: 2147483647 small4: -2147483648 ---- small1 & mask: 0 small2 & mask: 1 small3 & mask: 2147483647 small4 & mask: 0
Thanks, and sorry for the lengthy response, -Noah Botimer
Andi Gutmans wrote:
Actually I think it'd be a good idea to discuss it here on [EMAIL PROTECTED] We should reach some understanding about this problem and if we consider it a bug or not.
Andi
At 02:02 PM 10/5/2004 +0200, Derick Rethans wrote:
On Tue, 5 Oct 2004, Wez Furlong wrote:
> Feels like a major bug to me... this got into a release? :-/
Yes, please keep the discussion about this in the bugreport, and not on the list.
Derick
-- Derick Rethans http://derickrethans.nl | http://ez.no | http://xdebug.org
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php