#27208 [Opn->Bgs]: ~ operator produces incorrect result under Linux

From: Date: Tue, 10 Feb 2004 15:58:07 +0000
Subject: #27208 [Opn->Bgs]: ~ operator produces incorrect result under Linux
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-54695@lists.php.net to get a copy of this message
ID: 27208 Updated by: iliaa@php.net Reported By: tonyman_hacker at yahoo dot com -Status: Open +Status: Bogus Bug Type: Scripting Engine problem Operating System: Linux PHP Version: 4.3.4 New Comment: Works fine on linux. php -r ' printf("%x\n", ~ 0x1); ' fffffffe Previous Comments: ------------------------------------------------------------------------ [2004-02-10 10:18:21] tonyman_hacker at yahoo dot com Description: ------------ I've founded that under Linux the ~ bit operator doesn't produce correct result; Reproduce code: --------------- $myvar = 0x1; $myvar = ~$myvar; // the result of this operation on windows system is correct // 0xFFFFFFFE // on Linux we have 0xFFFFFFFF echo dechex($myvar); Expected result: ---------------- // the result of this operation on windows system is correct // 0xFFFFFFFE // on Linux we have 0xFFFFFFFF Actual result: -------------- // the result of this operation on windows system is correct // 0xFFFFFFFE // on Linux we have 0xFFFFFFFF instead of this you could use XOR operator ... i.e. ~$myvar = $myvar ^ 0xFFFFFFFF ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=27208&edit=1

« previous php.bugs (#54695) next »