#38225 [Opn->Bgs]: ">>" gives unexpected results

From: Date: Mon, 14 Aug 2006 22:14:16 +0000
Subject: #38225 [Opn->Bgs]: ">>" gives unexpected results
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-100797@lists.php.net to get a copy of this message
ID: 38225 Updated by: nlopess@php.net Reported By: bretschneider at cleverbridge dot com -Status: Open +Status: Bogus Bug Type: Math related Operating System: Linux 2.6.12-1.1381_FC3 PHP Version: 5.1.4 New Comment: I can't reproduce anything. I get the same results with PHP and C (gcc 3.4). Previous Comments: ------------------------------------------------------------------------ [2006-07-26 15:41:38] 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 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=38225&edit=1

« previous php.bugs (#100797) next »