why isn't 0.1235 * 10 equals 1.235 in python?

Viewed 61

I am using python 3.6.8 and tried to multiply 0.1235 with 10 and the answer is 1.2349999999999999 rather than 1.235. After importing the decimal module, when we multiply decimal.Decimal(0.1235) with 10 we get Decimal('1.234999999999999986677323704') rather than Decimal('1.235'). So How to do precision float calculations with python?

1 Answers
Related