Print a float number in normal form, not exponential form / scientific notation
63,935
Solution 1
You can format it as a fixed-point number.
>>> a = 1/1221759
>>> '{0:.10f}'.format(a)
'0.0000008185'
Solution 2
You can use print formatting:
print "%.16f" % a
where 16 is the number of digits you want after the decimal point.
Author by
kafedakias
Updated on July 22, 2020Comments
-
kafedakias almost 4 years
I have a number that prints out in exponential form:
>>> >>> a = 1/1221759 >>> print(a) 8.184920266599223e-07 >>>
How can i make it print in normal form?
-
niken almost 8 yearsreturns '0.0000000000' for me?
-
Peter Badida almost 8 years@Nik because Python 2.7 returns int with
/
operator. Py3 returns float. Put a decimal point at the end of1221759