"rounding" a negative exponential in python
floating-point, formatting, python
Solution
This gets you pretty close, do you need `8.e-58` exactly or are you just trying to shorten it into something readable?
>>> x = 8.54768039530728989343156856E-58
>>> print "{0:.1e}".format(x)
8.5e-58
An alternative:
>>> print "{0:.0e}".format(x)
9e-58
Note that on Python 2.7 or 3.1+, you can omit the first zero which indicates the position, so it would be something like `"{:.1e}".format(x)`
Problem
I am looking to convert some small numbers to a simple, readable output. Here is my method but I wondering if there is something simpler. ``` x = 8.54768039530728989343156856E-58 y = str(x) print "{0}.e{1}".format(y.split(".")[0], y.split("e")[1]) 8.e-58 ```