/** * {@inheritdoc} */ public function toBigRational() { return BigRational::create($this, BigInteger::one(), false); }
/** * 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); }
public function testOne() { $this->assertBigIntegerEquals('1', BigInteger::one()); $this->assertSame(BigInteger::one(), BigInteger::one()); }