예제 #1
0
 /**
  * Logical Right Shift
  *
  * Shifts BigInteger's by $shift bits, effectively dividing by 2**$shift.
  *
  * @param int $shift
  * @return Math_BigInteger
  * @access public
  * @internal The only version that yields any speed increases is the internal version.
  */
 function bitwise_rightShift($shift)
 {
     $temp = new Math_BigInteger();
     switch (MATH_BIGINTEGER_MODE) {
         case MATH_BIGINTEGER_MODE_GMP:
             static $two;
             if (!isset($two)) {
                 $two = gmp_init('2');
             }
             $temp->value = gmp_div_q($this->value, gmp_pow($two, $shift));
             break;
         case MATH_BIGINTEGER_MODE_BCMATH:
             $temp->value = bcdiv($this->value, bcpow('2', $shift, 0), 0);
             break;
         default:
             // could just replace _lshift 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->_rshift($shift);
     }
     return $this->_normalize($temp);
 }
예제 #2
0
 public function bitwise_rightShift($shift)
 {
     $temp = new Math_BigInteger();
     switch (MATH_BIGINTEGER_MODE) {
         case MATH_BIGINTEGER_MODE_GMP:
             static $two;
             if (!isset($two)) {
                 $two = gmp_init('2');
             }
             $temp->value = gmp_div_q($this->value, gmp_pow($two, $shift));
             break;
         case MATH_BIGINTEGER_MODE_BCMATH:
             $temp->value = bcdiv($this->value, bcpow('2', $shift, 0), 0);
             break;
         default:
             $temp->value = $this->value;
             $temp->_rshift($shift);
     }
     return $this->_normalize($temp);
 }