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 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:
18 - 16 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2020 The PHP Group
All rights reserved.
Last updated: Fri Dec 04 06:01:23 2020 UTC