# https://docs.python.org/3/library/decimal.html from decimal import * print(0.1 + 0.1 + 0.1) # Sets decimal to 25 digits of precision getcontext().prec = 25 print(Decimal(0.1) + Decimal(0.1) + Decimal(0.1)) # Sets decimal to 50 digits of precision getcontext().prec = 50 print(Decimal(0.1) + Decimal(0.1) + Decimal(0.1)) # Sets decimal to 100 digits of precision getcontext().prec = 100 print(Decimal(0.1) + Decimal(0.1) + Decimal(0.1)) # Sets decimal to 200 digits of precision getcontext().prec = 200 a = Decimal(0.1) + Decimal(0.1) + Decimal(0.1) print(a) # Sets decimal to i digits of precision for i in range(10,1000,10): getcontext().prec = i a = Decimal(1.0) / Decimal(3.0) print(a)