Hacker News new | ask | show | jobs
by Joker_vD 853 days 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.

1 comments

And 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.