Returns the modulus of an integer

@param  string|int   $number
@param  int          $divider
@param  array        $items array of items to select from to return

@return int
192467
public function modulusFilter($number, $divider, $items = null)
    {
        if (\is_string($number)) {
            $number = strlen($number);
        }

        $remainder = $number % $divider;

        if (\is_array($items)) {
            return $items[$remainder] ?? $items[0];
        }

        return $remainder;
    }
1168252
private static function checksum(string $number) : int
    {
        $number = strrev($number);
        $length = strlen($number);

        $sum = 0;

        for ($i = 0; $i < $length; $i++) {
            $value = $number[$i] * ($i % 2 + 1);
            $sum += ($value >= 10 ? $value - 9 : $value);
        }

        return $sum % 10;
    }
914317
public static function divide(array ...$arrays): array
    {
        self::checkArrayLengths($arrays);

        $number_of_arrays = count($arrays);
        $length_of_arrays = count($arrays[0]);
        $quotients        = array_map(
            function ($x) {
                return $x;
            },
            $arrays[0]
        );

        for ($i = 0; $i < $length_of_arrays; $i++) {
            for ($j = 1; $j < $number_of_arrays; $j++) {
                $quotients[$i] /= $arrays[$j][$i];
            }
        }

        return $quotients;
    }
1279724
public static function mod10($number)
    {
        $checksum = '';
        foreach (str_split(strrev((string) $number)) as $i => $d) {
            $checksum .= ($i % 2 == 0) ? $d * 2 : $d;
        }
        return array_sum(str_split($checksum)) * 9 % 10;
    }
833855
public function number($number, $decimals = 0)
    {
        if (!$this->localizer) {
            return number_format($number, $decimals);
        }

        return $this->localizer->number($number, $decimals);
    }
892412
public function divide($divisor, $roundingMode = self::ROUND_HALF_UP)
    {
        $this->assertOperand($divisor);
        $this->assertRoundingMode($roundingMode);

        $divisor = (string) Number::fromNumber($divisor);

        if ($this->getCalculator()->compare($divisor, '0') === 0) {
            throw new \InvalidArgumentException('Division by zero');
        }

        $quotient = $this->round($this->getCalculator()->divide($this->amount, $divisor), $roundingMode);

        return $this->newInstance($quotient);
    }
1213002
private double round(double number) {
        boolean isNegative = isNegative(number);
        if (isNegative)
            number = -number;

        // Apply rounding after multiplier
        if (roundingDouble > 0.0) {
            // number = roundingDouble
            //    * round(number / roundingDouble, roundingMode, isNegative);
            return round(
                number, roundingDouble, roundingDoubleReciprocal, roundingMode,
                isNegative);
        }
        return number;
    }
610580
function _divide_digit($dividend, $divisor)
    {
        $carry = 0;
        $result = array();

        for ($i = count($dividend) - 1; $i >= 0; --$i) {
            $temp = self::$baseFull * $carry + $dividend[$i];
            $result[$i] = $this->_safe_divide($temp, $divisor);
            $carry = (int) ($temp - $divisor * $result[$i]);
        }

        return array($result, $carry);
    }
1155884
public function divide($number): Utility
    {
        $divisible = new static($number);

        if ($divisible->value() == 0 || $this->number == 0) {
            throw new DivisionByZeroError();
        }

        $value = $this->number / $divisible->value();

        return new static($value);
    }
247267
public static function item(array $item, ?int $number = null): string
    {
        if ($number !== null) {
            $number = '#'.$number.' ';
        }
        return $number.self::point($item).': '.self::method($item);
    }
750141
@Override
    public Money divide(Number divisor) {
        if (NumberVerifier.isInfinityAndNotNaN(divisor)) {
            return Money.of(0, getCurrency());
        }
        BigDecimal divisorBD = MoneyUtils.getBigDecimal(divisor);
        if (divisorBD.equals(BigDecimal.ONE)) {
            return this;
        }
        BigDecimal dec =
                this.number.divide(divisorBD, MoneyUtils.getMathContext(getContext(), RoundingMode.HALF_EVEN));
        return new Money(dec, getCurrency());
    }
447439
private function round($number)
    {
        if (null !== $this->precision && null !== $this->roundingMode) {
            // shift number to maintain the correct precision during rounding
            $roundingCoef = pow(10, $this->precision);
            $number *= $roundingCoef;

            switch ($this->roundingMode) {
                case \NumberFormatter::ROUND_CEILING:
                    $number = ceil($number);
                    break;
                case \NumberFormatter::ROUND_FLOOR:
                    $number = floor($number);
                    break;
                case \NumberFormatter::ROUND_UP:
                    $number = $number > 0 ? ceil($number) : floor($number);
                    break;
                case \NumberFormatter::ROUND_DOWN:
                    $number = $number > 0 ? floor($number) : ceil($number);
                    break;
                case \NumberFormatter::ROUND_HALFEVEN:
                    $number = round($number, 0, PHP_ROUND_HALF_EVEN);
                    break;
                case \NumberFormatter::ROUND_HALFUP:
                    $number = round($number, 0, PHP_ROUND_HALF_UP);
                    break;
                case \NumberFormatter::ROUND_HALFDOWN:
                    $number = round($number, 0, PHP_ROUND_HALF_DOWN);
                    break;
            }

            $number /= $roundingCoef;
        }

        return $number;
    }
1064662
public static function SplitIntoSegments($number)
	{
		$number_str = $number->GetStringValue();
		$segments = [];
		$NumberSegments = [];

		while (strlen($number_str) > 0)
		{
			if (strlen($number_str) < 3)
			{
				$segments[] = $number_str;

				break;
			}

			$segment = substr($number_str, -3);
			$number_str = substr($number_str, 0, strlen($number_str) - 3);

			$segments[] = $segment;
		}

		return array_reverse($segments);
	}
1250999
public static function getCheckDigit(string $number) : int
    {
        if (! ctype_digit($number)) {
            throw new \InvalidArgumentException('The number must be a string of digits');
        }

        $checksum = self::checksum($number . '0');

        return ($checksum === 0) ? 0 : 10 - $checksum;
    }
438562
public function divide($number = null)
    {
        if ($number === null) {
            $this->internalSetOperationModeWithHistory('divide');
        } elseif ($number instanceof Closure) {
            $this->internalSetOperationModeWithHistory('divide');
            return $this->group($number);
        } else {
            $this->performOperationOnExpressionEngine('divide', $number);
        }

        return $this;
    }
1294481
@Override
    public FastMoney[] divideAndRemainder(Number divisor) {
        if (isInfinityAndNotNaN(divisor)) {
            FastMoney zero = new FastMoney(0L, getCurrency());
            return new FastMoney[]{zero, zero};
        }
        checkNumber(divisor);
        BigDecimal div = MoneyUtils.getBigDecimal(divisor);
        BigDecimal[] res = getBigDecimal().divideAndRemainder(div);
        return new FastMoney[]{new FastMoney(res[0], getCurrency(), true), new FastMoney(res[1], getCurrency(), true)};
    }
103706
public function computeWithoutBcMath(DecimalNumber $a, DecimalNumber $b, $precision = self::DEFAULT_PRECISION)
    {
        $bString = (string) $b;
        if ('0' === $bString) {
            throw new DivisionByZeroException();
        }

        $aString = (string) $a;

        // 0 as dividend always yields 0
        if ('0' === $aString) {
            return $a;
        }

        // 1 as divisor always yields the dividend
        if ('1' === $bString) {
            return $a;
        }

        // -1 as divisor always yields the the inverted dividend
        if ('-1' === $bString) {
            return $a->invert();
        }

        // if dividend and divisor are equal, the result is always 1
        if ($a->equals($b)) {
            return new DecimalNumber('1');
        }

        $aPrecision = $a->getPrecision();
        $bPrecision = $b->getPrecision();

        $maxPrecision = max($aPrecision, $bPrecision);

        if ($maxPrecision > 0) {
            // make $a and $b integers by multiplying both by 10^(maximum number of decimals)
            $a = $a->toMagnitude($maxPrecision);
            $b = $b->toMagnitude($maxPrecision);
        }

        $result = $this->integerDivision($a, $b, max($precision, $aPrecision));

        return $result;
    }