B
beliavsky
By default, Python prints many floating point numbers with 17 digits
after the decimal place. I would like to make the DEFAULT 4 decimal
places. Is this possible?
For example, the code
from string import join
x = [1.0,0.3,0.4]
print x
print join(["%4.1f" % y for y in x])
gives the output
[1.0, 0.29999999999999999, 0.40000000000000002]
1.0 0.3 0.4
I want the simplicity of "print x", without so many decimal places.
after the decimal place. I would like to make the DEFAULT 4 decimal
places. Is this possible?
For example, the code
from string import join
x = [1.0,0.3,0.4]
print x
print join(["%4.1f" % y for y in x])
gives the output
[1.0, 0.29999999999999999, 0.40000000000000002]
1.0 0.3 0.4
I want the simplicity of "print x", without so many decimal places.