Re:How to compare floats in Python
by caturopath on Wednesday March 30, 2022 @06:33PM
(#30861660)
> It does, but those issues manifest themselves in ways that humans have been trained to operate.
Not really. If you do computations like "convert Fahrenheit to Celsius" or "pay 6 days of interest at this APR" or a million other things, you run into the same basic faulty assumptions as ever
Rounding to even makes sense for human-facing decimals as well.
That's what they do in accounting, I think? At least Wikipedia tells me it's also called banker's rounding.
Incidentally, it's also what Python's Decimal does by default. See https://docs.python.org/3/library/decimal.html#rounding-mode...
"Round to nearest even" for binary floating point is weird to anyone who doesn't have a numerics background. "Round 0.5 up" is normal to humans because that's what most have been taught.
Future programming languages should probably default to Decimal Floating Point and allow people to opt-in to binary floating point on request.