Skip to content

Commit

Permalink
SmartNumber: Add support for small numbers.
Browse files Browse the repository at this point in the history
  • Loading branch information
janbarasek authored Jan 23, 2020
1 parent 4360a9c commit 4af83b1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Entity/SmartNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ private function setFractionHelper(string $float, float $tolerance = 1.e-8): arr
return $this->fraction = ['0', '1'];
}

if (preg_match('/^0+\.(?<zeros>0{3,})(?<num>\d+?)$/', $float, $floatParser)) {
return $this->fraction = [$floatParser['num'], '1' . str_repeat('0', \strlen($floatParser['zeros']) + 2)];
}

$floatOriginal = $float;
$float = preg_replace('/^-/', '', $float);

Expand Down

0 comments on commit 4af83b1

Please sign in to comment.