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

Breadcrumb

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

function BigInteger::mod

Returns the modulo of this number and the given one.

The modulo operation yields the same result as the remainder operation when both operands are of the same sign, and may differ when signs are different.

The result of the modulo operation, when non-zero, has the same sign as the divisor.

Parameters

BigNumber|int|float|string $that The divisor. Must be convertible to a BigInteger.:

Throws

DivisionByZeroException If the divisor is zero.

File

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

Class

BigInteger
An arbitrary-size integer.

Namespace

Brick\Math

Code

public function mod(BigNumber|int|float|string $that) : BigInteger {
    $that = BigInteger::of($that);
    if ($that->value === '0') {
        throw DivisionByZeroException::modulusMustNotBeZero();
    }
    $value = Calculator::get()->mod($this->value, $that->value);
    return new BigInteger($value);
}

API Navigation

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