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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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: Sun Dec 22 03:01:28 2024 UTC