php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #6369 Bitwise OR does not work with negative numbers
Submitted: 2000-08-26 13:55 UTC Modified: 2000-08-26 14:17 UTC
From: jonny at 1409 dot org Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 4.0.1pl2 OS: Linux 2.2.16
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: jonny at 1409 dot org
New email:
PHP Version: OS:

 

 [2000-08-26 13:55 UTC] jonny at 1409 dot org
Bitwise OR does not work with negative numbers, example:

number 1: -123456789 (10000111010110111100110100010100)
number 2:   234567890 (00001101111110110011100011010010)

Result:
10000111010110111100110100010100
00001101111110110011100011010010
10000010000000001100010100000100

A bit in the resulting number is only set, if it's set in the first
number and NOT set in the second number!?

This does only occur if one number is negative, with two positive
numbers it works fine.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-08-26 14:17 UTC] stas@php.net
I wonder where do you get these values?
-123456789 is 0xf8a432eb or 11111000101001000011001011101011
the second number is right.
the result of ORing is: -33604869
which is 11111101111111110011101011111011.

Where's the problem?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 09 23:01:32 2024 UTC