3 ms·
> At the end of the day, 0.1 + 0.2 != 0.3 is a fact you have to live with. But 0.1 + 0.2 == 0.3 — if you round both sides to 2 (or however many you need) decim
by Joker_vD 3y ago
> At the end of the day, 0.1 + 0.2 != 0.3 is a fact you have to live with.
But 0.1 + 0.2 == 0.3 — if you round both sides to 2 (or however many you need) decimal points before comparing them.
- masklinn 3y agoAnd that’s a problem, now you have to round-off defensively which complexifies the code and you have to decide how often and how defensively you round things. Plus you’ve got the added fun that fp rounding routines don’t necessarily take a rounding mode.