From d87853119aa6f11e3251f3eacd541f517af2c2b9 Mon Sep 17 00:00:00 2001 From: Benjamin Morel Date: Thu, 31 Mar 2016 19:24:40 +0200 Subject: [PATCH] Backport #6 bugfix --- src/BigDecimal.php | 2 +- tests/BigDecimalTest.php | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) 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],