|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17116 Bitwise & does not give expected results for positive numbers
Submitted: 2002-05-09 08:17 UTC Modified: 2002-07-01 17:39 UTC
From: lindsay dot marshall at ncl dot ac dot uk Assigned:
Status: Closed Package: Math related
PHP Version: 4.2.0 OS: redhat 7.2
Private report: No CVE-ID: None
 [2002-05-09 08:17 UTC] lindsay dot marshall at ncl dot ac dot uk
I have a piece of code that effectively does this :

$r->f = 8191;
$c->m = 7;

$r->f & $c->m returns 0!!

The above code works fine when tested standalone, but the equivalent code in my program generates 0. I can write ;

echo $r->status.' '.$current->mask.' '.($r->status&$current->mask);

and the output I get is

8191 7 0

If I write :

echo $r->status.' '.$current->mask.' '.($a1&$a2);

I get

8191 7 7

Something is getting confused somewhere!!


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-09 08:27 UTC] lindsay dot marshall at ncl dot ac dot uk
I just tried the following:

$a1 = $r->status;
$a2 = $current->mask;
echo $a1.' '.$a2.' '.($a1&$a2);

And it still prints out 8191 7 0

I feel as though I am doing something really stupid here,  but cannot for the life of me see what it is.
 [2002-05-09 08:32 UTC] lindsay dot marshall at ncl dot ac dot uk
Oh, and before you say "BOGUS - see 7755"

1) I am not using negative integers
2) I think that 7755 is a serious bug and needs to be fixed properly as someone else commented.
3) It is clearly intermittent or at least depends on past history in some way.
 [2002-05-09 09:08 UTC]
1) You sure you aren't &'ing strings together?  
2) 7755 has been fixed - try it
3) Doubt that
 [2002-07-01 15:41 UTC]
Please reopen this report if this problem is still not fixed for you.

 [2002-07-01 17:39 UTC]
Just close it..

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 12 18:01:31 2024 UTC