How can get following formatting (input values are always less than 0.1):
> formatting(0.09112346)
0.91123E-01
> formatting(0.00112346)
0.11234E-02
and so on.
I am looking for some elegant solution. I am already using a custom function given below:
def formatting(x, prec=5):
tup = x.as_tuple()
digits = list(tup.digits[:prec])
dec = ''.join(str(i) for i in digits)
exp = x.adjusted()
return '0.{dec}E{exp}'.format(dec=dec, exp=exp)