diff --git a/src/BigDecimal.php b/src/BigDecimal.php index cc9168c..31f13bb 100644 --- a/src/BigDecimal.php +++ b/src/BigDecimal.php @@ -286,7 +286,7 @@ public function dividedBy($that, $roundingMode = RoundingMode::UNNECESSARY, $sca } } - if ($that->value === '1' && $scale === $this->scale) { + if ($that->value === '1' && $that->scale === 0 && $scale === $this->scale) { return $this; } diff --git a/tests/BigDecimalTest.php b/tests/BigDecimalTest.php index 489f393..72d1fbc 100644 --- a/tests/BigDecimalTest.php +++ b/tests/BigDecimalTest.php @@ -567,6 +567,9 @@ public function providerDividedBy() ['-7', '0.2', null, RoundingMode::UNNECESSARY, '-35', 0], ['-7', '-0.2', null, RoundingMode::UNNECESSARY, '35', 0], + ['1234567890123456789', '0.01', 0, RoundingMode::UNNECESSARY, '123456789012345678900', 0], + ['1234567890123456789', '0.010', 0, RoundingMode::UNNECESSARY, '123456789012345678900', 0], + ['1324794783847839472983.343898', '1', null, RoundingMode::UNNECESSARY, '1324794783847839472983343898', 6], ['-32479478384783947298.3343898', '1', null, RoundingMode::UNNECESSARY, '-324794783847839472983343898', 7],