Page 1 of 1

PHP Bug?

Posted: Tue Aug 02, 2005 12:21 pm
by brettsg
How come this code in PHP version 4.4 does something different than in version 4.3?

$val = 538759009 ^ 0xAABBCCDD;
print "val=" . $val;

= 2326201276 (version 4.4)

and

= -1968766020 (version 4.3)

I want the behavior of version 4.4, but I'm not quite sure what it is doing differently than in version 4.3. Any ideas?

Thanks in advance! :wink:

Posted: Tue Aug 02, 2005 1:04 pm
by anjanesh
PHP 5.0.3

Code: Select all

val=-1968766020

Posted: Tue Aug 02, 2005 1:16 pm
by josh
Try http://us3.php.net/bcpow, might not fix it but it's worth a shot eh?

I didn't find anything in the manual about the issue you're having, hopefully feyd or one of the other phpdn forum gods will come clear this issue up as it has me stumped as well.

Posted: Tue Aug 02, 2005 1:17 pm
by brettsg
anjanesh wrote:PHP 5.0.3

Code: Select all

val=-1968766020
Weird... any ideas why 4.4 might differ? Also is there an equivalent of the C++ function atol() in PHP? I wonder if 4.4 is taking the ASCII value of 538759009.

Posted: Tue Aug 02, 2005 1:25 pm
by josh
brettsg wrote:Also is there an equivalent of the C++ function atol() in PHP?
http://us3.php.net/manual/en/language.t ... ggling.php
Scroll down to type casting

Posted: Tue Aug 02, 2005 1:32 pm
by brettsg
jshpro2 wrote:
brettsg wrote:Also is there an equivalent of the C++ function atol() in PHP?
http://us3.php.net/manual/en/language.t ... ggling.php
Scroll down to type casting
I tried:
$val = (string)(538759009) ^ 0xAABBCCDD;
print "val=" . $val;
val=-1968766020

How can I duplicate the version 4.4 behavior (i.e. val=2326201276)?