Skip to content

Commit

Permalink
Backport #6 bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMorel committed Mar 31, 2016
1 parent e04b04d commit 69706f8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/BigDecimal.php
Expand Up @@ -283,7 +283,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;
}

Expand Down
3 changes: 3 additions & 0 deletions tests/BigDecimalTest.php
Expand Up @@ -568,6 +568,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],

Expand Down

0 comments on commit 69706f8

Please sign in to comment.