note 109792 modified in language.operators.bitwise by aharvey

From: 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.&#13;&#10;&#13;&#10;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&#13;&#10;&#13;&#10;Example:&#13;&#10;&#13;&#10;LEFT SHIFT&#13;&#10;&#60;?php echo 8 &#60;&#60; 3; //64 ?&#62;&#13;&#10;&#13;&#10;//same as&#13;&#10;&#60;?php echo 8 * 2 * 2 * 2; ?&#62;&#13;&#10;&#13;&#10;RIGHT SHIFT&#13;&#10;&#60;?php echo 8 &#62;&#62; 3; //1 ?&#62;&#13;&#10;&#13;&#10;//same as&#13;&#10;&#60;?php echo ((8/2)/2)/2; //1 ?&#62;&#13;&#10;&#13;&#10;//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

« previous php.notes (#190464) next »