Answers for "how to set precision for float values"

2

fixed precision float python

x = 13.949999999999999999
g = float("{:.2f}".format(x))
Posted by: Guest on May-20-2020
-1

python decimal precision, float

#!/usr/bin/python

from decimal import Decimal

x = 1 / 3
print(type(x))
print(x)

print("-----------------------")

y = Decimal(1) / Decimal(3)
print(type(y))
print(y)
Posted by: Guest on June-25-2021

Code answers related to "how to set precision for float values"

Python Answers by Framework

Browse Popular Code Answers by Language