Exemplo n.º 1
0
 /**
  * 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.
  */
 public function power($exponent)
 {
     $exponent = (int) $exponent;
     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);
 }