When converting to float or decimal, the values are not correct. Below are some examples:
"{0:.20f}".format(0.1) = '0.10000000000000000555'
"{0:.20f}".format(1/3) = '0.33333333333333331483'
Decimal(2.4) = Decimal('2.399999999999999911182158029987476766109466552734375')
The above behavior is causing problems when rounding numbers. e.g. I expect round(6.345, 2) to be equal to 6.35, but it comes out to be 6.34, probably because Decimal(6.345) evaluates to 6.34499999999999975131004248396493494510650634765625, which is closer to 6.34, than 6.35.
Why does this happen? What is the work-around for this?