Re: Bitwise NOT operator?
| From: | Richard Quadling | Date: | Tue, 24 Aug 2010 15:06:07 +0000 |
| Subject: | Re: Bitwise NOT operator? | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-307645@lists.php.net to get a copy of this message | ||
On 20 August 2010 17:00, Andy McKenzie <amckenzie4@gmail.com> wrote:
> Thanks to everyone who responded. I've dealt with binary math
> before, but it never occurred to me (and doesn't seem to be anywhere
> in the document page at php.net!) that it would automatically pad the
> number I entered.
There is no padding.
php -r "echo decbin(~2), PHP_EOL, decbin(-3);"
11111111111111111111111111111101
11111111111111111111111111111101
That's 100% correct and proper. Not "padded".
The example in [1] regarding E_ALL & ~E_NOTICE is a perfect example.
Richard.
[1] http://docs.php.net/manual/en/language.operators.bitwise.php
--
Richard Quadling.