note 74720 deleted from language.operators.bitwise by danielc
| From: | danielc@php.net | Date: | Mon, 13 Apr 2009 16:13:00 +0000 |
| Subject: | note 74720 deleted from language.operators.bitwise by danielc | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-153164@lists.php.net to get a copy of this message | ||
Note Submitter: don dot hosek at gmail dot com
Reason: 0
----
Don't forget operator precedence. == has a higher precedence than does & so in the cases
that you've written
if (9 & 8 == 8) echo 'true'; else echo 'false';
is the same as 9 & (8 ==8) which is 9 & true or 9 & 1 which is 1 which is true
if (8 & 8 == 8) echo 'true'; else echo 'false';
is the same as 8 & (8 == 8) which is 8 & true or 8 & 1 which is 0 which is false
Putting in parentheses is required to cause the bitwise and to take place before the comparison.