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

Breadcrumb

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

function BrickMathCalculator::divide

Overrides CalculatorInterface::divide

File

vendor/ramsey/uuid/src/Math/BrickMathCalculator.php, line 80

Class

BrickMathCalculator
A calculator using the brick/math library for arbitrary-precision arithmetic

Namespace

Ramsey\Uuid\Math

Code

public function divide(int $roundingMode, int $scale, NumberInterface $dividend, NumberInterface ...$divisors) : NumberInterface {
    $brickRounding = $this->getBrickRoundingMode($roundingMode);
    $quotient = BigDecimal::of($dividend->toString());
    foreach ($divisors as $divisor) {
        $quotient = $quotient->dividedBy($divisor->toString(), $scale, $brickRounding);
    }
    if ($scale === 0) {
        return new IntegerObject((string) $quotient->toBigInteger());
    }
    return new Decimal((string) $quotient);
}

API Navigation

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