note 109792 modified in language.operators.bitwise by aharvey
| From: | aharvey@php.net | Date: | Tue, 04 Sep 2012 01:13:10 +0000 |
| Subject: | note 109792 modified in language.operators.bitwise by aharvey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-190464@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; //64
?> //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
<?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
http://php.net/manual/en/language.operators.bitwise.php