Wow, what a vicious footgun. I do a lot of work related to pricing, invoicing, exchange rates etc... where decimals do matter, so this kind of stresses me out. Thanks for the heads up.
0.1 is not representable in binary floating point. The old behavior was adding magic that shouldn't be there.
> Wow, what a vicious footgun.
We do too at $dayjob, but use cents for everything and at the end of the calculation we divide by 100 to get the dollar amount.
Exchange rates are 4 decimals, so you would still not get bit by this.
You shouldn’t cast from double to decimal anyway. Just use decimal throughout.