Divide a value

@param int|float $number The number

@throws DivisionByZeroException
@return Calculate
425327
public function divide($number)
    {
        if (Number::isZero($number)) {
            throw new DivisionByZeroException;
        }

        $this->number = $this->number / $number;

        return $this;
    }
697062
public function divide(
        Money $money,
        $fraction
    ): Money {
        return new Money(
            $money->getAmount() / $fraction,
            $money->getCurrency()
        );
    }
1110104
private function normalizeNumber($number)
    {
        if (!is_numeric($number)) {
            throw new InvalidArgumentException('Number expected');
        }

        $number = floatval($number);

        if ($number < 0) {
            throw new InvalidArgumentException('The number expected was >= 0');
        }

        return max($number, 1);
    }
1075130
public function setParcelNumber($number)
    {
        $this->set(Config::T8904, (string)$number);
        $this->set(Config::T8973, (string)$number);

        return $this;
    }
905110
public function setMinor($number)
    {
        if (!Validator::isNumber($number)) {
            throw new InvalidNumberException($number);
        }

        $this->minor = intval($number);

        return $this;
    }
58066
public function multiply($number = null)
    {
        if ($number === null) {
            $this->internalSetOperationModeWithHistory('multiply');
        } elseif ($number instanceof Closure) {
            $this->internalSetOperationModeWithHistory('multiply');
            return $this->group($number);
        } else {
            $this->performOperationOnExpressionEngine('multiply', $number);
        }

        return $this;
    }
833580
private function normalize()
    {
        $gcd = Math::gcd($this->p, $this->q);

        if ($gcd == 0) throw new DivisionByZeroException();

        $this->p = $this->p/$gcd;
        $this->q = $this->q/$gcd;

        if ($this->q < 0) {
            $this->p = -$this->p;
            $this->q = -$this->q;
        }
    }
26422
public function divide($value)
    {
        if (!$value instanceof self) {
            $value = new self($value, $this->getScale(), false);
        }

        $rawValue = $value->getValue();
        if ($rawValue == 0) {
            throw new InvalidArgumentException('Cannot divide by zero.');
        }

        $newValue = bcdiv($this->getValue(), $rawValue, $this->getScale());

        return $this->assignValue($newValue);
    }
349090
public function lessStrict($number)
    {
        if (!is_int($number) && !is_float($number)) {
            throw new InvalidIntOrFloatException('number', $number);
        }

        if (!is_int($this->value) && !is_float($this->value)) {
            throw new InvalidIntOrFloatException($this->name, $this->value);
        } elseif ($this->value >= $number) {
            throw new NumberNotLessStrictlyException($this->name, $this->value, $number);
        }

        return $this;
    }
1040930
public function number($number, $decimals = 0)
    {
        return number_format(
            (float) $number,
            $decimals,
            $this->get('number')['decimal_separator'],
            $this->get('number')['thousands_separator']
        );
    }
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;
    }
1331105
public function divide($divisor, $roundingMode = self::ROUND_HALF_UP, $precision = self::PRECISION_GAAP)
    {
        $this->assertRoundingMode($roundingMode);
        $divisor = $this->castOperand($divisor);
        $precision = $this->castPrecision($precision);

        $innerPrecision = $this->getInnerPrecision();
        if ($divisor->isZero($innerPrecision)) {
            throw new Exception\InvalidArgumentException('Division by zero');
        }

        $amount = $this->amount->div($divisor, $innerPrecision + 1);

        if (null === $roundingMode) {
            $amount = $amount->round($precision);
        } else {
            $amount = Math::bcround($amount, $precision, $roundingMode);
        }

        return $this->newInstance($amount);
    }
384664
private static function prepareFloat($number): float
	{
		if ($number === null) {
			return 0;
		} elseif (is_numeric($number)) {
			return (float) $number;
		} else {
			throw new InvalidArgumentException("Value must be a number");
		}
	}
1085707
public final static Function<Long, Long> divideBy(Number divisor, RoundingMode roundingMode) {
        return new Divide(fromNumber(divisor), roundingMode);
    }
1105165
public function divide($divisor, $roundingMode = self::ROUND_HALF_UP)
    {
        $this->assertOperand($divisor);
        $this->assertRoundingMode($roundingMode);

        if ($divisor == 0) {
            throw new InvalidArgumentException('Division by zero');
        }

        return new self(round($this->amount / $divisor, $this->currency->getPrecision(), $roundingMode), $this->currency);
    }
1159986
public function minus($number)
    {
        self::mustBeNumeric($number, 'Value to substract');
        
        $number = is_object($number) ? $number->value : $number;
        
        return new self($this->value - $number);
    }
699171
public void Divide(double scalar) {

        if (scalar == 0) {
            try {
                throw new ArithmeticException("Can not divide by zero.");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        this.real /= scalar;
        this.imaginary /= scalar;
    }