Beispiel #1
0
 /**
  * Logical Exclusive-Or
  *
  * @param Math_BigInteger $x
  * @access public
  * @internal Implemented per a request by Lluis Pamies i Juarez <lluis _a_ pamies.cat>
  * @return Math_BigInteger
  */
 function bitwise_xor($x)
 {
     switch (MATH_BIGINTEGER_MODE) {
         case MATH_BIGINTEGER_MODE_GMP:
             $temp = new Math_BigInteger();
             $temp->value = gmp_xor($this->value, $x->value);
             return $temp;
         case MATH_BIGINTEGER_MODE_BCMATH:
             return new Math_BigInteger($this->toBytes() ^ $x->toBytes(), 256);
     }
     $result = new Math_BigInteger();
     $x_length = count($x->value);
     for ($i = 0; $i < $x_length; $i++) {
         $result->value[] = $this->value[$i] ^ $x->value[$i];
     }
     return $result->_normalize();
 }