Answer the question
In order to leave comments, you need to log in
How to convert floating point number 6.737e-0.5 to number like 0.000023233?
How to convert floating point number 6.737e-0.5 to number like 0.000023233?
I display the price of an asset and it is constantly displayed in the format of a floating point number, but I need ordinary numbers with any number of digits. The search turned up nothing.
Answer the question
In order to leave comments, you need to log in
You can use the f format specifier and specify the number of decimal digits:
>>> '{:.10f}'.format(1e-10)
'0.0000000001'
>>> '{:f}'.format(1e-6)
'0.000001'
>>> '{:f}'.format(1e-7)
'0.000000'
rstrip
:>>> '{:f}'.format(1.1)
'1.100000'
>>> '{:f}'.format(1.1).rstrip('0')
'1.1'
>>> '{:.16f}'.format(1.1)
'1.1000000000000001'
>>> 1.1
1.1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question