Performs the division of two non-signed large integers.

@param string $a The first operand.
@param string $b The second operand.

@return string[] The quotient and remainder.
543231
private function doDiv(string $a, string $b) : array
    {
        $cmp = $this->doCmp($a, $b);

        if ($cmp === -1) {
            return ['0', $a];
        }

        $x = \strlen($a);
        $y = \strlen($b);

        // we now know that a >= b && x >= y

        $q = '0'; // quotient
        $r = $a; // remainder
        $z = $y; // focus length, always $y or $y+1

        for (;;) {
            $focus = \substr($a, 0, $z);

            $cmp = $this->doCmp($focus, $b);

            if ($cmp === -1) {
                if ($z === $x) { // remainder < dividend
                    break;
                }

                $z++;
            }

            $zeros = \str_repeat('0', $x - $z);

            $q = $this->add($q, '1' . $zeros);
            $a = $this->sub($a, $b . $zeros);

            $r = $a;

            if ($r === '0') { // remainder == 0
                break;
            }

            $x = \strlen($a);

            if ($x < $y) { // remainder < dividend
                break;
            }

            $z = $y;
        }

        return [$q, $r];
    }
1024289
public function call($a, $b)
    {
        return $a * ($b / $this->gcdMath->call($a, $b));
    }
1007456
public static function intersection(array $a, array $b): array
    {
        $a = (array)$a;
        $b = (array)$b;

        return array_values(array_intersect($a, $b));
    }
190206
public function compute(array $a, array $b) : float
    {
        $a = Vector::quick($a);
        $b = Vector::quick($b);

        return 1. - ($a->dot($b) / ($a->l2Norm() * $b->l2Norm()));
    }
285125
public function computeUsingBcMath(DecimalNumber $a, DecimalNumber $b)
    {
        $precision1 = $a->getPrecision();
        $precision2 = $b->getPrecision();
        return new DecimalNumber((string) bcadd($a, $b, max($precision1, $precision2)));
    }
588406
private function doSub(string $a, string $b) : string
    {
        if ($a === $b) {
            return '0';
        }

        // Ensure that we always subtract to a positive result: biggest minus smallest.
        $cmp = $this->doCmp($a, $b);

        $invert = ($cmp === -1);

        if ($invert) {
            $c = $a;
            $a = $b;
            $b = $c;
        }

        $length = $this->pad($a, $b);

        $carry = 0;
        $result = '';

        $complement = 10 ** $this->maxDigits;

        for ($i = $length - $this->maxDigits;; $i -= $this->maxDigits) {
            $blockLength = $this->maxDigits;

            if ($i < 0) {
                $blockLength += $i;
                $i = 0;
            }

            $blockA = \substr($a, $i, $blockLength);
            $blockB = \substr($b, $i, $blockLength);

            $sum = $blockA - $blockB - $carry;

            if ($sum < 0) {
                $sum += $complement;
                $carry = 1;
            } else {
                $carry = 0;
            }

            $sum = (string) $sum;
            $sumLength = \strlen($sum);

            if ($sumLength < $blockLength) {
                $sum = \str_repeat('0', $blockLength - $sumLength) . $sum;
            }

            $result = $sum . $result;

            if ($i === 0) {
                break;
            }
        }

        // Carry cannot be 1 when the loop ends, as a > b
        assert($carry === 0);

        $result = \ltrim($result, '0');

        if ($invert) {
            $result = $this->neg($result);
        }

        return $result;
    }
1193194
public static function __reduceType($a, $b)
    {
        if (is_array($b)) {
            return array_reduce($b, array('SectionEvent', '__reduceType'));
        }

        return (strlen(trim($b)) === 0) ? 'missing' : 'invalid';
    }
38201
function mult($a, $b)
    {
        $sum = $this->ltable[$a] + $this->ltable[$b];
        $sum %= 255;
        // Get the antilog
        $sum = $this->atable[$sum];

        return ($a == 0 ? 0 : ($b == 0 ? 0 : $sum));
    }
242890
public function div($a, $b)
    {
        $a = $this->convert($a);
        $b = $this->convert($b);
        switch ($this->arbitrate($a, $b)) {
            case 'int':
            case 'whole':
            case 'natural':
                return $this->calcEngine->intDiv($a, $b);
            case 'rational':
                return $this->calcEngine->rationalDiv($a, $b);
            case 'complex':
                return $this->calcEngine->complexDiv($a, $b);
            case 'complex:numeric':
                return $this->calcEngine->complexDiv($a, $b->asComplex());
            case 'numeric:complex':
                return $this->calcEngine->complexDiv($a->asComplex(), $b);
            default:
                return $this->calcEngine->floatDiv($a, $b);
        }
    }
197658
public function add($a, $b)
    {
        return bcadd($this->bcNormalize($a), $this->bcNormalize($b));
    }
192706
public static function mod(int $a, int $b) : int
    {
        return ($a % $b) + ($a < 0 ? $b : 0);
    }
1174463
protected function x_or($a, $b)
    {
        $length = strlen($a);
        for($i = 0; $i < $length; $i++) {
            $a[$i] = $a[$i] ^ $b[$i];
        }
        
        return $a;
    }
1370853
public function add($a, $b)
    {
        $a = $this->convert($a);
        $b = $this->convert($b);

        switch ($this->arbitrate($a, $b)) {
            case 'int':
                return $this->calcEngine->intAdd($a, $b);
            case 'float':
                return $this->calcEngine->floatAdd($a, $b);
            case 'whole':
                return $this->calcEngine->wholeAdd($a, $b);
            case 'natural':
                return $this->calcEngine->naturalAdd($a, $b);
            case 'rational':
                return $this->calcEngine->rationalAdd($a, $b);
            case 'complex':
                return $this->calcEngine->complexAdd($a, $b);
            case 'complex:numeric':
                return $this->calcEngine->complexAdd($a, $b->asComplex());
            case 'numeric:complex':
                return $this->calcEngine->complexAdd($a->asComplex(), $b);
        }
    }
78486
public function power($a, $b)
    {
        return bcpow($this->bcNormalize($a), $this->bcNormalize($b));
    }
1218298
public function Subtract($a, $b)
    {
        $this->preOpMethodParamsCheck(array($a, $b));

        return $this->math->sub($a, $b);
    }
1269112
public static function gcd($a, $b)
    {
        $ta = abs($a);
        $tb = abs($b);
        while ($tb != 0) {
            $tmp = $tb;
            $tb = $ta % $tb;
            $ta = $tmp;
        }
        
        return $ta;
    }
533890
public static function cartesian(Set $a, Set $b) : array
    {
        $cartesian = [];

        foreach ($a as $multiplier) {
            foreach ($b as $multiplicand) {
                $cartesian[] = new self(array_merge([$multiplicand], [$multiplier]));
            }
        }

        return $cartesian;
    }