Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. BigRational.php

function BigRational::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/BigRational.php, line 263

Class

BigRational
An arbitrarily large rational number.

Namespace

Brick\Math

Code

public function power(int $exponent) : BigRational {
    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);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal