note 24568 deleted from language.operators.bitwise by sniper

From: Date: Mon, 13 Oct 2003 00:12:32 +0000
Subject: note 24568 deleted from language.operators.bitwise by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-58407@lists.php.net to get a copy of this message
Note Submitter: TheDrJoint@hotmail.com ---- This functions can be used for rotating the bits of an integer value(32-bit). There are operators for that in C/C++(<<< and >>>). // Rotates $a, $b times to the left function RotateLeft($a, $b){ $s = $a << $b; $c = $a >> (32 - $b); $s = $s | $c; return intval($s); } // Rotates $a, $b times to the right function RotateRight($a, $b){ $s = $a >> $b; $c = $a << (32 - $b); $s = $s | $c; return intval($s); } //Exapmle: RotateRight(13, 68); //returns -805306368 RotateRight(13, 31); //returns 26 RotateRight(13, 32); //returns 13 RotateLeft(13, 68); //returns 208 RotateLeft(13, 31); //returns -2147483642 RotateLeft(13, 32); //returns 13

« previous php.notes (#58407) next »