예제 #1
0
파일: BigInteger.php 프로젝트: brick/math
 /**
  * {@inheritdoc}
  */
 public function toBigRational()
 {
     return BigRational::create($this, BigInteger::one(), false);
 }
예제 #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);
 }
예제 #3
0
 public function testOne()
 {
     $this->assertBigIntegerEquals('1', BigInteger::one());
     $this->assertSame(BigInteger::one(), BigInteger::one());
 }