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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: tonyman_hacker at yahoo dot com
New email:
PHP Version: OS:

 

 [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

Add a Patch

Pull Requests

Add a Pull Request

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: Sun Apr 28 18:01:31 2024 UTC