function BigInteger::power
Returns this number exponentiated to the given value.
Throws
\InvalidArgumentException If the exponent is not in the range 0 to 1,000,000.
File
-
vendor/
brick/ math/ src/ BigInteger.php, line 456
Class
- BigInteger
- An arbitrary-size integer.
Namespace
Brick\MathCode
public function power(int $exponent) : BigInteger {
if ($exponent === 0) {
return BigInteger::one();
}
if ($exponent === 1) {
return $this;
}
if ($exponent < 0 || $exponent > Calculator::MAX_POWER) {
throw new \InvalidArgumentException(\sprintf('The exponent %d is not in the range 0 to %d.', $exponent, Calculator::MAX_POWER));
}
return new BigInteger(Calculator::get()->pow($this->value, $exponent));
}