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

Breadcrumb

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

function NativeCalculator::pow

Overrides Calculator::pow

File

vendor/brick/math/src/Internal/Calculator/NativeCalculator.php, line 182

Class

NativeCalculator
Calculator implementation using only native PHP code.

Namespace

Brick\Math\Internal\Calculator

Code

public function pow(string $a, int $e) : string {
    if ($e === 0) {
        return '1';
    }
    if ($e === 1) {
        return $a;
    }
    $odd = $e % 2;
    $e -= $odd;
    $aa = $this->mul($a, $a);
    
    /** @psalm-suppress PossiblyInvalidArgument We're sure that $e / 2 is an int now */
    $result = $this->pow($aa, $e / 2);
    if ($odd === 1) {
        $result = $this->mul($result, $a);
    }
    return $result;
}

API Navigation

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