diff --git a/src/BigDecimal.php b/src/BigDecimal.php index 8efe1c0..ef93b2b 100644 --- a/src/BigDecimal.php +++ b/src/BigDecimal.php @@ -211,15 +211,15 @@ public function multipliedBy($that) * Returns the result of the division of this number by the given one, at the given scale. * * @param BigNumber|number|string $that The divisor. - * @param int $scale The desired scale. + * @param int|null $scale The desired scale, or null to use the scale of this number. * @param int $roundingMode An optional rounding mode. * * @return BigDecimal * - * @throws \InvalidArgumentException If the rounding mode is invalid. + * @throws \InvalidArgumentException If the scale or rounding mode is invalid. * @throws ArithmeticException If the number is invalid, is zero, or rounding was necessary. */ - public function dividedBy($that, $scale, $roundingMode = RoundingMode::UNNECESSARY) + public function dividedBy($that, $scale = null, $roundingMode = RoundingMode::UNNECESSARY) { $that = BigDecimal::of($that); diff --git a/tests/BigDecimalTest.php b/tests/BigDecimalTest.php index 19cb72b..1c751f6 100644 --- a/tests/BigDecimalTest.php +++ b/tests/BigDecimalTest.php @@ -578,12 +578,12 @@ public function providerMultipliedBy() /** * @dataProvider providerDividedBy * - * @param string $a The base number. - * @param string $b The number to multiply. - * @param int $scale The desired scale of the result. - * @param int $roundingMode The rounding mode. - * @param string $unscaledValue The expected unscaled value of the result. - * @param int $expectedScale The expected scale of the result. + * @param string $a The base number. + * @param string $b The number to divide. + * @param int|null $scale The desired scale of the result. + * @param int $roundingMode The rounding mode. + * @param string $unscaledValue The expected unscaled value of the result. + * @param int $expectedScale The expected scale of the result. */ public function testDividedBy($a, $b, $scale, $roundingMode, $unscaledValue, $expectedScale) { @@ -606,6 +606,7 @@ public function providerDividedBy() ['-32479478384783947298.3343898', '1', 7, RoundingMode::UNNECESSARY, '-324794783847839472983343898', 7], ['1.5', '2', 2, RoundingMode::UNNECESSARY, '75', 2], + ['1.5', '3', null, RoundingMode::UNNECESSARY, '5', 1], ['0.123456789', '0.00244140625', 10, RoundingMode::UNNECESSARY, '505679007744', 10], ['1.234', '123.456', 50, RoundingMode::DOWN, '999546397096941420425090720580611715914981855883', 50], ['1', '3', 10, RoundingMode::UP, '3333333334', 10],