php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27208 ~ operator produces incorrect result under Linux
Submitted: 2004-02-10 10:18 UTC Modified: 2004-02-10 10:58 UTC
From: tonyman_hacker at yahoo dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.3.4 OS: Linux
Private report: No CVE-ID: None
 [2004-02-10 10:18 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-02-10 10:58 UTC] iliaa@php.net
Works fine on linux. 
 
php -r ' printf("%x\n", ~ 0x1); ' 
fffffffe 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 14:01:30 2024 UTC