Search code examples
pythonstringformatscientific-notation

PYTHON - Changing very small numbers as string to float (scientific notation)


i have a string like '0.00008400' and i just want to turn it 0.00008400 (float). But python changes it to scientific notation type and it is looking like 8.4e-05,

float('0.00008400') = 8.4e-05 #as float

I saw some formatting answers but they are turning it to string instead of float.

format(8.4e-05, '.8f') = 0.00008400 #as string

and of course I can't turn this string value into float again...

#stupid alert
float(format(8.4e-05, '.8f')) = 8.4e-05

I just want to my string type input to turn float exactly...

'0.00008400' => 0.00008400 #string to float

Thanks in advance...

Edit: there is a function that I want to use gets float value but can't understand scientific notion format of float. So this is why I want to show this float normal. SORRY: string format is okay too. Sorry.


Solution

  • The scientific representation is "just" a representation of your float, that does not change the real value of the float, whatever how python display it.

    So I don't understand what you want to do. Could you send more informations ?