php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38225 ">>" gives unexpected results
Submitted: 2006-07-26 15:41 UTC Modified: 2006-08-14 22:14 UTC
From: bretschneider at cleverbridge dot com Assigned:
Status: Not a bug Package: Math related
PHP Version: 5.1.4 OS: Linux 2.6.12-1.1381_FC3
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: bretschneider at cleverbridge dot com
New email:
PHP Version: OS:

 

 [2006-07-26 15:41 UTC] bretschneider at cleverbridge dot com
Description:
------------
 ">>" gives unexpected results

Reproduce code:
---------------
$x = 0x00FFFF00;
printf("0x%8X\n", ($x >> 8));       // I get "0x    FFFF"
printf("0x%8X\n", ($x << 8) >> 8);  // I get 0xFFFFFF00 (bad)
printf("0x%8X\n", ($x << 0) >> 8);  // I get 0xFFFFFFFF (bad)

$x = 0xFFFFFFFF;
printf("0x%8X\n", ($x >> 8) << 8);  // I get 0xFFFFFF00 (bad)

Expected result:
----------------
0x    FFFF
0x  FFFF00
0x  FFFFFF
0x  FFFF00

Actual result:
--------------
0x    FFFF
0xFFFFFF00
0xFFFFFFFF
0xFFFFFF00

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-14 22:14 UTC] nlopess@php.net
I can't reproduce anything. I get the same results with PHP and C (gcc 3.4).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 06 17:01:27 2024 UTC