Q:

Convert scientific notation to decimal with no trailing zeros

I would like to have floats printed out

in decimal notation
with no trailing zeros

For instance:
1e-5    -> 0.00001
1.23e-4 -> 0.000123
1e-8    -> 0.00000001

Some things that don't work:
str(x) outputs scientific notation for small floats
format(x, 'f') and "{:f}".format(x) have fixed number of decimals, thus leave trailing zeroes
('%f' % x).rstrip('0').rstrip('.') rounds 1e-8 to 0
from decimal import Decimal
(Decimal('0.00000001000').normalize())

uses scientific notation
%0.10f requires that I know ahead of time the precision of my floats

A:

If you numbers are consistently like this, you could just modify the string:
number = "1.23155e-8" # as a string
lead, power = number.split("e-")
a, b = lead.split(".")
number = "0." + "0"*(int(power)-1) + a + b

print(number)

edit: fixed it.

