PHP 4.0 Bug #6368: Bitwise NOT does not work

From: Date: Sat, 26 Aug 2000 16:56:05 +0000
Subject: PHP 4.0 Bug #6368: Bitwise NOT does not work
Groups: php.dev 
Request: Send a blank email to php-dev+get-30767@lists.php.net to get a copy of this message
From: jonny@1409.org Operating system: Linux 2.2.16 PHP version: 4.0.1pl2 PHP Bug Type: Misbehaving function Bug description: Bitwise NOT does not work Maybe i'm just too stupid, but this one is strange: The logical operator ~ (bitwise NOT) does not behave as expected. When doing a "~1" (00000000000000000000000000000001), i get 2 (10000000000000000000000000000001) so it only seems to invert the first bit?! Furthermore when doing some simple mathematicaloperations, PHP behaves extremely annoing. Right-shifting (>>) a negative number will always produce a negative result, i.e. the +/- bit gets not shifted. Although you are right when you claim that this one is ok, there are situations when you want the sign bit to get also shifted, and there seems to be no simple way for doing that in PHP :-(

« previous php.dev (#30767) next »