Returns this number exponentiated to the given value.

@param int $exponent The exponent.

@return BigRational The result.

@throws \InvalidArgumentException If the exponent is not in the range 0 to 1,000,000.
971593
public function power(int $exponent) : BigRational
    {
        if ($exponent === 0) {
            $one = BigInteger::one();

            return new BigRational($one, $one, false);
        }

        if ($exponent === 1) {
            return $this;
        }

        return new BigRational(
            $this->numerator->power($exponent),
            $this->denominator->power($exponent),
            false
        );
    }
531018
public static double pow(Number baseNumber, int exponent) {
        return exponent < 1 ? 1
                : exponent > 1
                ? baseNumber.doubleValue()
                * pow(baseNumber, exponent - 1)
                : baseNumber.doubleValue();
    }
1357058
final public static function byOrdinal(int $ordinal)
    {
        if (!isset(self::$names[static::class])) {
            self::detectConstants(static::class);
        }

        if (!isset(self::$names[static::class][$ordinal])) {
            throw new InvalidArgumentException(\sprintf(
                'Invalid ordinal number %s, must between 0 and %s',
                $ordinal,
                \count(self::$names[static::class]) - 1
            ));
        }

        $name = self::$names[static::class][$ordinal];
        if (isset(self::$instances[static::class][$name])) {
            return self::$instances[static::class][$name];
        }

        return self::$instances[static::class][$name] = new static(self::$constants[static::class][$name], $ordinal);
    }
584118
protected function doMatch($actual = null)
    {
        if (isset($this->countable)) {
            $actual = $this->getCount();
        }

        if (!is_numeric($actual)) {
            throw new \InvalidArgumentException(get_class($this) . ' requires a numeric value');
        }

        return $this->matchNumeric($actual);
    }
688406
public function getBytes($count)
    {
        $count = (int) $count;

        if ($count < 0) {
            throw new \InvalidArgumentException('Number of bytes must be 0 or more');
        }

        return $this->generator->getBytes($count);
    }
1066318
public function getInteger($min, $max)
    {
        $min = (int) $min;
        $max = (int) $max;

        if ($this->isOutOfBounds($min, 0, $max)) {
            throw new \InvalidArgumentException('Invalid minimum or maximum value');
        }

        return $this->generator->getNumber($min, $max);
    }
866703
public function exp(int $scale = null): Decimal
    {
        if ($this->isZero()) {
            return DecimalConstants::one();
        }

        $scale = $scale ?? \max(
            $this->scale,
            (int)($this->isNegative() ? self::innerLog10($this->value, $this->scale, 0) : self::DEFAULT_SCALE)
        );

        return self::factorialSerie(
            $this, DecimalConstants::one(), function ($i) { return DecimalConstants::one(); }, $scale
        );
    }
421639
public function modulus($modulus)
    {
        if (!is_numeric($modulus)) {
            throw new \InvalidArgumentException('Modulus must be numeric');
        }

        $amount = bcmod($this->amount, strval($modulus));

        return self::valueOf($amount, $this->currency);
    }
601112
public function pNorm(float $p = 3.)
    {
        if ($p <= 0.) {
            throw new InvalidArgumentException('P must be greater'
                . " than 0, $p given.");
        }

        return $this->abs()->powScalar($p)->sum() ** (1. / $p);
    }
892412
public function divide($divisor, $roundingMode = self::ROUND_HALF_UP)
    {
        $this->assertOperand($divisor);
        $this->assertRoundingMode($roundingMode);

        $divisor = (string) Number::fromNumber($divisor);

        if ($this->getCalculator()->compare($divisor, '0') === 0) {
            throw new \InvalidArgumentException('Division by zero');
        }

        $quotient = $this->round($this->getCalculator()->divide($this->amount, $divisor), $roundingMode);

        return $this->newInstance($quotient);
    }
995818
public static function fromNumber($number)
    {
        if (is_float($number)) {
            return self::fromString(sprintf('%.14F', $number));
        }

        if (is_int($number)) {
            return new self($number);
        }

        if (is_string($number)) {
            return self::fromString($number);
        }

        throw new \InvalidArgumentException('Valid numeric value expected');
    }
688960
public function normalizeDeclaration($declaration)
    {
        if (is_string($declaration)) {
            return $this->normalizeString($declaration);
        }

        // Normalize numerically indexed array
        if (array_keys($declaration) === array_keys(array_values($declaration))) {
            return $this->normalizeArray($declaration);
        }

        if (isset($declaration['arguments']) && !is_array($declaration['arguments'])) {
            throw new \InvalidArgumentException('The "arguments" parameter should be an array of arguments.');
        }

        // Adds default value to associative array
        return array_merge(['method' => null, 'required' => true, 'arguments' => []], $declaration);
    }
214134
public function get(string $algorithm): Algorithm
    {
        if (!$this->has($algorithm)) {
            throw new \InvalidArgumentException(\sprintf('The algorithm "%s" is not supported.', $algorithm));
        }

        return $this->algorithms[$algorithm];
    }
219566
public function getAmount($amount)
    {
        if (!is_float($amount) &&
            $this->getCurrencyDecimalPlaces() > 0 &&
            false === strpos((string) $amount, '.')) {
            throw new InvalidArgumentException(
                'Please specify amount as a string or float, '.
                'with decimal places (e.g. \'10.00\' to represent $10.00).'
            );
        }

        return $this->formatCurrency($amount);
    }
1084243
public function limit($limit)
    {
        if (null !== $limit) {
            if (!is_numeric($limit) || $limit != (int) $limit) {
                throw new \InvalidArgumentException('The limit is not valid.');
            }
            $limit = (int) $limit;
        }

        $this->limit = $limit;

        return $this;
    }
697832
public function pow(Decimal $b, int $scale = null): Decimal
    {
        if ($this->isZero()) {
            if ($b->isPositive()) {
                return Decimal::fromDecimal($this, $scale);
            } else {
                throw new \DomainException("zero can't be powered to zero or negative numbers.");
            }
        } elseif ($b->isZero()) {
            return DecimalConstants::One();
        } else if ($b->isNegative()) {
            return DecimalConstants::One()->div(
                $this->pow($b->additiveInverse(), max($scale, self::DEFAULT_SCALE)),
                max($scale, self::DEFAULT_SCALE)
            );
        } elseif (0 === $b->scale) {
            $pow_scale = \max($this->scale, $b->scale, $scale ?? 0);

            return self::fromString(
                \bcpow($this->value, $b->value, $pow_scale+1),
                $pow_scale
            );
        } else {
            if ($this->isPositive()) {
                $pow_scale = \max($this->scale, $b->scale, $scale ?? 0);

                $truncated_b = \bcadd($b->value, '0', 0);
                $remaining_b = \bcsub($b->value, $truncated_b, $b->scale);

                $first_pow_approx = \bcpow($this->value, $truncated_b, $pow_scale+1);
                $intermediate_root = self::innerPowWithLittleExponent(
                    $this->value,
                    $remaining_b,
                    $b->scale,
                    $pow_scale+1
                );

                return Decimal::fromString(
                    \bcmul($first_pow_approx, $intermediate_root, $pow_scale+1),
                    $pow_scale
                );
            } else { // elseif ($this->isNegative())
                if (!$b->isInteger()) {
                    throw new NotImplementedError(
                        "Usually negative numbers can't be powered to non integer numbers. " .
                        "The cases where is possible are not implemented."
                    );
                }

                return (\preg_match('/^[+\-]?[0-9]*[02468](\.0+)?$/', $b->value, $captures) === 1)
                    ? $this->additiveInverse()->pow($b, $scale)                      // $b is an even number
                    : $this->additiveInverse()->pow($b, $scale)->additiveInverse();  // $b is an odd number
            }
        }
    }
262494
public static Number power(Number self, Number exponent) {
        double base, exp, answer;
        base = self.doubleValue();
        exp = exponent.doubleValue();

        answer = Math.pow(base, exp);
        if ((double) ((int) answer) == answer) {
            return (int) answer;
        } else if ((double) ((long) answer) == answer) {
            return (long) answer;
        } else {
            return answer;
        }
    }