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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
29 + 13 = ?
Subscribe to this entry?

 
 [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: Tue May 14 07:01:33 2024 UTC