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

Breadcrumb

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

function BigInteger::modPow

Returns this number raised into power with modulo.

This operation only works on positive numbers.

Parameters

BigNumber|int|float|string $exp The exponent. Must be positive or zero.:

BigNumber|int|float|string $mod The modulus. Must be strictly positive.:

Throws

NegativeNumberException If any of the operands is negative.

DivisionByZeroException If the modulus is zero.

File

vendor/brick/math/src/BigInteger.php, line 621

Class

BigInteger
An arbitrary-size integer.

Namespace

Brick\Math

Code

public function modPow(BigNumber|int|float|string $exp, BigNumber|int|float|string $mod) : BigInteger {
    $exp = BigInteger::of($exp);
    $mod = BigInteger::of($mod);
    if ($this->isNegative() || $exp->isNegative() || $mod->isNegative()) {
        throw new NegativeNumberException('The operands cannot be negative.');
    }
    if ($mod->isZero()) {
        throw DivisionByZeroException::modulusMustNotBeZero();
    }
    $result = Calculator::get()->modPow($this->value, $exp->value, $mod->value);
    return new BigInteger($result);
}

API Navigation

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