note 109792 modified in language.operators.bitwise by danbrown

From: 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.&#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; //16 ?&#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 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

« previous php.notes (#190335) next »