Skip to content

Commit

Permalink
Merge pull request #18 from se8820726/main
Browse files Browse the repository at this point in the history
fix `convertENotationToRegularNumber` function to accept very small value
  • Loading branch information
mohammadanaraki authored Oct 22, 2024
2 parents 6480bbe + af620f8 commit 4df40ab
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions php/src/NumberFormatter.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php

// v1.0.4
namespace NumberFormatter;

class NumberFormatter
Expand Down Expand Up @@ -75,7 +75,7 @@ public function toMdString($input)
// Private methods...
private function isENotation($input)
{
return preg_match('/^[-+]?[0-9]*\.?[0-9]+([eE][-+][0-9]+)$/', $input);
return preg_match('/^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)$/', $input);
}

private function format($input)
Expand Down Expand Up @@ -477,6 +477,9 @@ private function reducePrecision($numberString, $precision = 30, $nonZeroDigits
private function convertENotationToRegularNumber($eNotation)
{
// Conversion logic for E-notation to regular number
return number_format($eNotation, 10, '.', '');
$decimalNotation = sprintf('%.20f', $eNotation);
return $decimalNotation;

//return number_format($eNotation, 10, '.', '');
}
}

0 comments on commit 4df40ab

Please sign in to comment.