I have two float values 1000.4 and 700.7
The result of 1000.4 - 700.7
returns me 299.69999999999993
. I did my research,Decimal would be a good option to do the calculation here print(Decimal('1000.4') - Decimal('700.7'))
and it returns 299.7
I have a question. what if I have a value 14.5
how can I print it as 14.50
?
I tried getcontext().prec = 2
and it didn't help and would made the print(Decimal('1000.4') - Decimal('700.7'))
returns 3.0E+2
which isn't what I want.