News for hackers. Stuff that matters.
Re:Why does 0.1 and 0.2 = 0.30000000000000004? by lr1970 on Wednesday February 08, 2023 @08:35PM (#34718553)
> PS. If you design software that works with money amounts, always use fixed point decimals. Don't use floats, it's just wrong!

Fundamental reason being that powers of 1/10 in decimal fractions are not always representable by powers of 1/2 in binary. Specifically 0.1 = 0b00011001100110011... is infinitely long binary string. Truncating it to any finite bit-width like 32 or 64 bits always introduces an error.

There are no comments on this comment yet.