Skip to content

Commit

Permalink
- fix: cleanup return values for older php versions that crash on tes…
Browse files Browse the repository at this point in the history
…t -0/0
  • Loading branch information
krowinski committed Feb 9, 2022
1 parent f4e940e commit 140d717
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/BCMathExtended/BC.php
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ public static function roundHalfEven(string $number, int $precision = 0): string
{
$number = static::convertScientificNotationToString($number);
if (!static::isFloat($number)) {
return static::parseNumber($number);
return $number;
}

$precessionPos = strpos($number, '.') + $precision + 1;
Expand Down Expand Up @@ -648,10 +648,10 @@ public static function round(string $number, int $precision = 0): string
$number = static::convertScientificNotationToString($number);
if (static::isFloat($number)) {
if (static::isNegative($number)) {
return static::sub($number, '0.' . str_repeat('0', $precision) . '5', $precision);
$number = static::sub($number, '0.' . str_repeat('0', $precision) . '5', $precision);
} else {
$number = static::add($number, '0.' . str_repeat('0', $precision) . '5', $precision);
}

return static::add($number, '0.' . str_repeat('0', $precision) . '5', $precision);
}

return static::parseNumber($number);
Expand Down

0 comments on commit 140d717

Please sign in to comment.