4 ms·
It's not a binary problem, it's a particular binary representation problem. You can represent 0.1 and 0.3 such that it terminates. In Java for example just use
by tpm 5y ago
It's not a binary problem, it's a particular binary representation problem. You can represent 0.1 and 0.3 such that it terminates. In Java for example just use BigDecimal (integer unscaled value + integer scale) and you are ok.
- josefx 5y agoThe floating point standard defines various float types, the common float/double types are called binary32 and binary64. It also defines decimal types. > integer unscaled value + integer scale binary float does the same, just using 2^exp instead of 10^exp for scale.