PHP Bug?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
brettsg
Forum Newbie
Posts: 10
Joined: Tue Aug 02, 2005 12:18 pm

PHP Bug?

Post 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:
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

PHP 5.0.3

Code: Select all

val=-1968766020
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post 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.
brettsg
Forum Newbie
Posts: 10
Joined: Tue Aug 02, 2005 12:18 pm

Post 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.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post 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
brettsg
Forum Newbie
Posts: 10
Joined: Tue Aug 02, 2005 12:18 pm

Post 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)?
Post Reply