Binary xor helper.

@param string $left
@param string $round

@return string Binary string.
555160
private function _binaryXor($left, $round)
    {
        $xOr = gmp_xor(
            gmp_init($left, 2),
            gmp_init($round, 2)
        );

        $bin = gmp_strval($xOr, 2);

        return str_pad($bin, $this->sideSize, '0', STR_PAD_LEFT);
    }
1225527
function bitwise_leftShift($shift)
    {
        $temp = new static();

        switch (MATH_BIGINTEGER_MODE) {
            case self::MODE_GMP:
                static $two;

                if (!isset($two)) {
                    $two = gmp_init('2');
                }

                $temp->value = gmp_mul($this->value, gmp_pow($two, $shift));

                break;
            case self::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);
    }
453809
public static Number xor(Number left, Number right) {
        return NumberMath.xor(left, right);
    }
1315037
public function add($left, $right) {
        if (empty($left)) {
            return $right;
        } elseif (empty($right)) {
            return $left;
        }
        $negative = '';
        if ($left[0] == '-' && $right[0] == '-') {
            $negative = '-';
            $left     = substr($left, 1);
            $right    = substr($right, 1);
        } elseif ($left[0] == '-') {
            return $this->subtract($right, substr($left, 1));
        } elseif ($right[0] == '-') {
            return $this->subtract($left, substr($right, 1));
        }
        $left   = $this->normalize($left);
        $right  = $this->normalize($right);
        $result = BaseConverter::convertFromBinary(
            $this->addBinary($left, $right),
            '0123456789'
        );
        return $negative . $result;
    }
312083
private function MultiplicationNeedsCdot($left, $right)
    {
        if ($left instanceof FunctionNode) {
            return true;
        }

        if ($this->isNumeric($right)) {
            return true;
        }

        if ($right instanceof ExpressionNode && $this->isNumeric($right->getLeft())) {
            return true;
        }

        return false;
    }
775846
public function left($n)
    {
        if ($n < 0 || $n > $this->size()) {
            return new MString($this->text);
        }

        $result = substr($this->text, 0, $n);

        if ($result === false) {
            return null;
        }

        return new MString($result);
    }
765089
private function numericExponent($leftOperand, $rightOperand)
    {
        // 0^0 throws an exception
        if ($this->isNumeric($leftOperand) && $this->isNumeric($rightOperand)) {
            if ($leftOperand->getValue() == 0 && $rightOperand->getValue() == 0)
            throw new DivisionByZeroException();
        }

        // x^0 = 1
        if ($rightOperand->getValue() == 0) return new IntegerNode(1);
        // x^1 = x
        if ($rightOperand->getValue() == 1) return $leftOperand;

        if (!$this->isNumeric($leftOperand) || !$this->isNumeric($rightOperand)) {
            return null;
        }
        $type = $this->resultingType($leftOperand, $rightOperand);

        // Compute x^y if both are numbers.
        switch($type) {
            case Node::NumericFloat:
            return new NumberNode(pow($leftOperand->getValue(), $rightOperand->getValue()));

            case Node::NumericInteger:
            if ($rightOperand->getValue() > 0)
            {
                return new IntegerNode(pow($leftOperand->getValue(), $rightOperand->getValue()));
            }
        }

        // No simplification found
        return null;
    }
736758
public static function or_(Expr $left, Expr $right) : BinOp
    {
        return new BinOp($left, BinOp::OR_, $right);
    }
294935
public static function equal(Expr $left, Expr $right) : BinOp
    {
        return new BinOp($left, BinOp::EQUAL, $right);
    }
3792
private static function doOperation( $token, $left, $right ) {
		if ( in_array( $token, [ 'in', 'not-in', 'within', 'not-within' ] ) ) {
			if ( !$right instanceof Range ) {
				$right = new Range( $right );
			}
		}
		switch ( $token ) {
			case 'or':
				return $left || $right;
			case 'and':
				return $left && $right;
			case 'is':
				return $left == $right;
			case 'is-not':
				return $left != $right;
			case 'in':
				return $right->isNumberIn( $left );
			case 'not-in':
				return !$right->isNumberIn( $left );
			case 'within':
				return $right->isNumberWithin( $left );
			case 'not-within':
				return !$right->isNumberWithin( $left );
			case 'mod':
				if ( is_int( $left ) ) {
					return (int)fmod( $left, $right );
				}

				return fmod( $left, $right );
			case ',':
				if ( $left instanceof Range ) {
					$range = $left;
				} else {
					$range = new Range( $left );
				}
				$range->add( $right );

				return $range;
			case '..':
				return new Range( $left, $right );
			default:
				throw new Error( "Invalid RPN token" );
		}
	}
235202
def binary_operation_logical(self, rule, left, right, **kwargs):
        
        return self.evaluate_binop_logical(rule.operation, left, right, **kwargs)
874278
public static function bytesToString(int $bytes, int $round = 0): string
    {
        return self::getMeasure($bytes, 0, $round);
    }
973660
public function getRoundCode($roundId)
    {
        $this->_ensureRounds();
        $roundCode = null;

        if (array_key_exists($roundId, $this->_rounds) && array_key_exists('gro_code', $this->_rounds[$roundId])) {
            $roundCode = $this->_rounds[$roundId]['gro_code'];
        }

        return $roundCode;
    }
1247084
protected function opAnd($left, $right, $shouldEval)
    {
        if (! $shouldEval) {
            return null;
        }

        if ($left !== static::$false and $left !== static::$null) {
            return $this->reduce($right, true);
        }

        return $left;
    }
1357582
public function subtract($left, $right) {
        if (empty($left)) {
            return $right;
        } elseif (empty($right)) {
            return $left;
        } elseif ($right[0] == '-') {
            return $this->add($left, substr($right, 1));
        } elseif ($left[0] == '-') {
            return '-' . $this->add(ltrim($left, '-'), $right);
        }
        $left    = $this->normalize($left);
        $right   = $this->normalize($right);
        $results = $this->subtractBinary($left, $right);
        $result  = BaseConverter::convertFromBinary($results[1], '0123456789');
        return $results[0] . $result;
    }
389176
final public static function binaryOperation(Expression $leftOperand, $operator, Expression $rightOperand)
    {
        return new BinaryOperationExpression(
                $leftOperand,
                $operator,
                $rightOperand);
    }
1213537
public function bitwiseAnd($x)
    {
        switch (MATH_BIGINTEGER_MODE) {
            case MATH_BIGINTEGER_MODE_GMP:
                $temp = new BigInteger();
                $temp->value = gmp_and($this->value, $x->value);

                return $this->protectedNormalize($temp);
            case MATH_BIGINTEGER_MODE_BCMATH:
                $left = $this->toBytes();
                $right = $x->toBytes();

                $length = max(strlen($left), strlen($right));

                $left = str_pad($left, $length, chr(0), STR_PAD_LEFT);
                $right = str_pad($right, $length, chr(0), STR_PAD_LEFT);

                return $this->protectedNormalize(new BigInteger($left & $right, 256));
        }

        $result = $this->copy();

        $length = min(count($x->value), count($this->value));

        $result->value = array_slice($result->value, 0, $length);

        for ($i = 0; $i < $length; ++ $i) {
            $result->value[$i] &= $x->value[$i];
        }

        return $this->protectedNormalize($result);
    }