Omit unneeded decimal points in modp_dtoa2() scientific notation output

For example, "1e-13" is now used instead of "1.e-13".
This commit is contained in:
Jon Siwek 2021-05-17 17:56:19 -07:00
parent 48ee0f31a1
commit 8996dfbfef
2 changed files with 7 additions and 3 deletions

View file

@ -55,6 +55,7 @@ static void sn_strip_trailing_zeros(char* str)
if ( ! frac ) if ( ! frac )
return; return;
char* start_dec = frac;
char* exp = 0; char* exp = 0;
char* trailing_zeros = 0; char* trailing_zeros = 0;
@ -80,6 +81,9 @@ static void sn_strip_trailing_zeros(char* str)
++frac; ++frac;
} }
if ( trailing_zeros == start_dec )
--trailing_zeros;
if ( trailing_zeros && exp ) if ( trailing_zeros && exp )
{ {
for ( ; ; ) for ( ; ; )

View file

@ -44,12 +44,12 @@ max double value = 1.7976931348623157e+308 (PASS)
0.5 0.5
5.0 5.0
1.e-13 1e-13
9.9999999999999998e-13 9.9999999999999998e-13
9.9999999999999994e-12 9.9999999999999994e-12
1.e-10 1e-10
1.0000000000000001e-09 1.0000000000000001e-09
1.e-08 1e-08
9.9999999999999995e-08 9.9999999999999995e-08
0.000001 0.000001