I have the following number of type float:
1.019e-05
To convert it to a decimal number, i did this:
print("%.10f" % float(1.019e-05))
Which gives the following output: 0.0000101900
The problem is that 0.0000101900
is of type str
, but i need to make some calculations with that number. How can i convert 0.0000101900
from string to a number again? if i use float()
the decimal will be converted again to an exponential. Am i forced to use the exponential number here?
The number is a float
and has the same value no matter how it looks - the scientific notation used is just a way of representing how the data looks in a more concise way. By doing your formatting string, you are formatting the number to look a certain way for output, but that creates a string representation of the number rather than "converting it to a decimal number". You can't change the way Python natively represents a float
, but I'm not understanding why this matters to you because it doesn't change the actual value of the number, just how it looks when printed out
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.