Skip to content

Comment on Rounding Percentagesparent

Comments

It is especially ill-defined when the input itself may have been rounded already, e.g. round(0.15, 1) = 0.1 because 0.15 is not exact in binary64 and the binary64 value closest to 0.15 is a bit smaller than 0.15. If you have to retain the exact rounded value for some reason, you should switch to fixed point from that point on.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.