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
Since this is the top result on Google, I will post here after failing to find a solution for my problem. If you are looking to format the display value of a float object and have it remain a float - not a string, you can use this solution:
Create a new class that modifies the way that float values are displayed.
from builtins import float
class FormattedFloat(float):
def __str__(self):
return "{:.10f}".format(self).rstrip('0')
You can modify the precision yourself by changing the integer values in {:f}