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

Breadcrumb

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

function BigInteger::dividedBy

Returns the result of the division of this number by the given one.

Parameters

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

RoundingMode $roundingMode An optional rounding mode, defaults to UNNECESSARY.:

Throws

MathException If the divisor is not a valid number, is not convertible to a BigInteger, is zero, or RoundingMode::UNNECESSARY is used and the remainder is not zero.

1 call to BigInteger::dividedBy()
BigInteger::shiftedRight in vendor/brick/math/src/BigInteger.php
Returns the integer right shifted by a given number of bits.

File

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

Class

BigInteger
An arbitrary-size integer.

Namespace

Brick\Math

Code

public function dividedBy(BigNumber|int|float|string $that, RoundingMode $roundingMode = RoundingMode::UNNECESSARY) : BigInteger {
    $that = BigInteger::of($that);
    if ($that->value === '1') {
        return $this;
    }
    if ($that->value === '0') {
        throw DivisionByZeroException::divisionByZero();
    }
    $result = Calculator::get()->divRound($this->value, $that->value, $roundingMode);
    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