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