示例#1
0
 /**
  * Logical Left Shift
  *
  * Shifts BigInteger's by $shift bits, effectively multiplying by 2**$shift.
  *
  * @param Integer $shift
  * @return BigInteger
  * @access public
  * @internal The only version that yields any speed increases is the internal version.
  */
 function bitwise_leftShift($shift)
 {
     $temp = new BigInteger();
     switch (MATH_BIGINTEGER_MODE) {
         case MATH_BIGINTEGER_MODE_GMP:
             static $two;
             if (!isset($two)) {
                 $two = gmp_init('2');
             }
             $temp->value = gmp_mul($this->value, gmp_pow($two, $shift));
             break;
         case MATH_BIGINTEGER_MODE_BCMATH:
             $temp->value = bcmul($this->value, bcpow('2', $shift, 0), 0);
             break;
         default:
             // could just replace _rshift with this, but then all _lshift() calls would need to be rewritten
             // and I don't want to do that...
             $temp->value = $this->value;
             $temp->_lshift($shift);
     }
     return $this->_normalize($temp);
 }