note 109792 modified in language.operators.bitwise by danbrown
| From: | danbrown@php.net | Date: | Fri, 31 Aug 2012 15:48:15 +0000 |
| Subject: | note 109792 modified in language.operators.bitwise by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-190335@lists.php.net to get a copy of this message | ||
Just learning Bitwise Shift Operators. The easiest way to resolve
a bitwise shift operators is my multiply or dividing each step by two for left shift or right shift
respectively Example: LEFT
SHIFT <?php echo 8 << 3; //16
?> //same as <?php echo 8 * 2 *
2 * 2; ?> RIGHT SHIFT <?php echo
8 >> 3; //1 ?> //same
as <?php echo ((8/2)/2)/2; //1
?> //Solving on a paper 8/2 = 4/2 = 2/2 = 1
--was--
Just learning Bitwise Shift Operators.
The easiest way to resolve a bitwise shift operators is my multiply or dividing each step by two
for left shift or right shift respectively
Example:
LEFT SHIFT
echo 8 << 3; //16
//same as
echo 8 * 2 * 2 * 2;
RIGHT SHIFT
echo 8 >> 3; //1
//same as
echo ((8/2)/2)/2; //1
//Solving on a paper 8/2 = 4/2 = 2/2 = 1
http://php.net/manual/en/language.operators.bitwise.php