Simplify an expression x^y, when y is numeric.

@param Node $leftOperand
@param Node $rightOperand
@retval Node|null
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;
    }
686677
public function expr($leftCond, $operator, $rightCond)
    {
        if (!$this->currentExpressionGroup) {
            throw new RuntimeException($this->translate(
                'Cannot add expression. Expression group is not started.'
            ));
        }
        $this->currentExpressionGroup->addExpression($leftCond, $operator, $rightCond);

        return $this;
    }
769959
@Pure /* not guaranteed, since compareTo() is invoked */
	@Inline("($1.compareTo($2) < 0)")
	public static <C> boolean operator_lessThan(Comparable<? super C> left, C right) {
		return left.compareTo(right) < 0;
	}
1180374
protected function numericFactors($leftOperand, $rightOperand)
    {
        if ($this->isNumeric($rightOperand) && $rightOperand->getValue() == 0) {
            throw new DivisionByZeroException();
        }
        if ($this->isNumeric($rightOperand) && $rightOperand->getValue() == 1)
        {
            return $leftOperand;
        }
        if ($this->isNumeric($leftOperand) && $leftOperand->getValue() == 0)
        {
            return new IntegerNode(0);
        }

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

        switch($type) {
            case Node::NumericFloat:
            return new NumberNode($leftOperand->getValue() / $rightOperand->getValue());

            case Node::NumericRational:
            case Node::NumericInteger:
            $p = $leftOperand->getNumerator() * $rightOperand->getDenominator();
            $q = $leftOperand->getDenominator() * $rightOperand->getNumerator();
            return new RationalNode($p, $q);
        }

        return null;
    }
1201682
private double doubleValue( double left, double right ) {
        switch( operator ) {
            case '+':
                return left + right;
            case '-':
                return left - right;
            case '*':
                return left * right;
            case '/':
                return left / right;
            default:
                throw createException( "Not supported Oprator '" + operator + "' for Expression '" + toString() + '\'' );
        }
    }
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;
    }
124259
public function operator($left, $operator, $right, $message = '')
    {
        if (!isset(static::$operators[$operator])) {
            throw new \InvalidArgumentException("Invalid operator $operator");
        }
        $this->assertion->setActual($left);

        return $this->assertion->{static::$operators[$operator]}($right, $message);
    }
587315
protected function mul($left, $right, $precision)
    {
        if (is_null($precision)) return $left * $right;
        return floatval(\bcmul($left, $right, $precision));
    }
571745
protected function op_number_number($op, $left, $right)
    {
        $unit = empty($left[2]) ? $right[2] : $left[2];

        $value = 0;
        switch ($op) {
        case '+':
            $value = $left[1] + $right[1];
            break;
        case '*':
            $value = $left[1] * $right[1];
            break;
        case '-':
            $value = $left[1] - $right[1];
            break;
        case '%':
            $value = $left[1] % $right[1];
            break;
        case '/':
            if ($right[1] == 0) {
                $this->throwError('parse error: divide by zero');
            }
            $value = $left[1] / $right[1];
            break;
        case '<':
            return $this->toBool($left[1] < $right[1]);
        case '>':
            return $this->toBool($left[1] > $right[1]);
        case '>=':
            return $this->toBool($left[1] >= $right[1]);
        case '=<':
            return $this->toBool($left[1] <= $right[1]);
        default:
            $this->throwError('parse error: unknown number operator: '.$op);
        }

        return array('number', $value, $unit);
    }
1155844
protected function opColorColor($op, $left, $right)
    {
        $out = [Type::T_COLOR];

        foreach ([1, 2, 3] as $i) {
            $lval = isset($left[$i]) ? $left[$i] : 0;
            $rval = isset($right[$i]) ? $right[$i] : 0;

            switch ($op) {
                case '+':
                    $out[] = $lval + $rval;
                    break;

                case '-':
                    $out[] = $lval - $rval;
                    break;

                case '*':
                    $out[] = $lval * $rval;
                    break;

                case '%':
                    $out[] = $lval % $rval;
                    break;

                case '/':
                    if ($rval == 0) {
                        $this->throwError("color: Can't divide by zero");
                        break 2;
                    }

                    $out[] = (int) ($lval / $rval);
                    break;

                case '==':
                    return $this->opEq($left, $right);

                case '!=':
                    return $this->opNeq($left, $right);

                default:
                    $this->throwError("color: unknown op $op");
                    break 2;
            }
        }

        if (isset($left[4])) {
            $out[4] = $left[4];
        } elseif (isset($right[4])) {
            $out[4] = $right[4];
        }

        return $this->fixColor($out);
    }
1133837
public static function add(Expr $left, Expr $right) : BinOp
    {
        return new BinOp($left, BinOp::ADD, $right);
    }
632151
public static Boolean or(Object left, Object right) {
        return (Boolean) InfixOpNode.or(left, right, null);
    }
997398
public static function doBinaryOperation($left, $operator, $right)
    {
        if (self::$binaryOperations === null) {
            self::$binaryOperations = [
                    self::BITWISE_AND              => function ($l, $r) { return $l & $r; },
                    self::BITWISE_OR               => function ($l, $r) { return $l | $r; },
                    self::BITWISE_XOR              => function ($l, $r) { return $l ^ $r; },
                    self::SHIFT_LEFT               => function ($l, $r) { return $l << $r; },
                    self::SHIFT_RIGHT              => function ($l, $r) { return $l >> $r; },
                    self::LOGICAL_AND              => function ($l, $r) { return $l && $r; },
                    self::LOGICAL_OR               => function ($l, $r) { return $l || $r; },
                    self::ADDITION                 => function ($l, $r) { return $l + $r; },
                    self::SUBTRACTION              => function ($l, $r) { return $l - $r; },
                    self::MULTIPLICATION           => function ($l, $r) { return $l * $r; },
                    self::DIVISION                 => function ($l, $r) { return $l / $r; },
                    self::MODULUS                  => function ($l, $r) { return $l % $r; },
                    //Compatible with < PHP 5.6
                    self::POWER                    => function ($l, $r) { return pow($l, $r); },
                    self::CONCATENATION            => function ($l, $r) { return $l . $r; },
                    self::IS_INSTANCE_OF           => function ($l, $r) { return $l instanceof $r; },
                    self::EQUALITY                 => function ($l, $r) { return $l == $r; },
                    self::IDENTITY                 => function ($l, $r) { return $l === $r; },
                    self::INEQUALITY               => function ($l, $r) { return $l != $r; },
                    self::NOT_IDENTICAL            => function ($l, $r) { return $l !== $r; },
                    self::LESS_THAN                => function ($l, $r) { return $l < $r; },
                    self::LESS_THAN_OR_EQUAL_TO    => function ($l, $r) { return $l <= $r; },
                    self::GREATER_THAN             => function ($l, $r) { return $l > $r; },
                    self::GREATER_THAN_OR_EQUAL_TO => function ($l, $r) { return $l >= $r; },
            ];
        }

        if (!isset(self::$binaryOperations[$operator])) {
            throw new PinqException('Binary operator \'%s\' is not supported', $operator);
        }

        $operation = self::$binaryOperations[$operator];

        return $operation($left, $right);
    }
750045
public static function isGreaterThan(Version $left, Version $right)
    {
        return (self::GREATER_THAN === self::compareTo($left, $right));
    }
288061
public static And and(Expression<Boolean> left, Expression<Boolean> right) {
        return new And(left, right);
    }
279567
def binary_operation_math(self, rule, left, right, **kwargs):
        
        if isinstance(left, NumberRule) and isinstance(right, NumberRule):
            return self._calculate_operation_math(rule, left, right)
        return self._compile_operation_rule(
            rule,
            left,
            right,
            MathBinOpRule
        )
450109
public static Object div(Object left, BigDecimal right) {
        return right == null || right.signum() == 0 ? null : InfixOpNode.div(left, right, null);
    }