On 17/04/2020 12:40, Aakash Jana wrote:
I am running python 3.8 only but my issue is I need more zeroes after my
result.
I want 2/5 = 0.400000
But I am only getting 0.4
When you just print or display a floating point number, Python only uses
as many digits as needed if the answer happens to be a (small enough)
exact decimal [*].
>>> foo = 2/5
>>> print(foo)
0.4
If you want the number displayed differently, you have to format it
yourself.
>>> print("{:6f}".format(foo))
0.400000
[*]: Since floats are stored internally in the standard IEEE *binary*
format, what constitutes an *exact* decimal may be a little surprising!
--
Rhodri James *-* Kynesim Ltd
--
https://mail.python.org/mailman/listinfo/python-list