note 14312 deleted from language.types.type-juggling by jeroen
| From: | jeroen@php.net | Date: | Sun, 02 Sep 2001 18:31:18 +0000 |
| Subject: | note 14312 deleted from language.types.type-juggling by jeroen | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-17540@lists.php.net to get a copy of this message | ||
It seems that sometimes, you need a little type juggling when doing bitwise operations. Here's
what happened to me (this was not the exact code, but the values are the same) :
$a = 7;
$b = 256;
Later on, I did ($a & $b) with those exact values and got a result of 7, which is mathematically
wrong.
To those of you who get this kind of error, it helps by converting the scalars to integer values :
((integer)$a & (integer)$b) works a lot better.
Hope I saved you time
Carl