Here\'s my code:
x = 1.0
y = 100000.0
print x/y
My quotient displays as 1.00000e-05
.
Is there any way to suppress
Most of the answers above require you to specify precision. But what if you want to display floats like this, with no unnecessary zeros:
1
0.1
0.01
0.001
0.0001
0.00001
0.000001
0.000000000001
numpy
has an answer: np.format_float_positional
import numpy as np
def format_float(num):
return np.format_float_positional(num, trim='-')