3 ms·
There’s no way to represent 1/3 as a decimal float. It’s a problem with any base.
by krallja 8y ago
There’s no way to represent 1/3 as a decimal float. It’s a problem with any base.
- vardump 8y agoNot a problem in bases divisible by 3. It's exactly 0.1 in base 3 and 0.4 in base 12, for example.
- krallja 8y agoThat’s exactly my point. Every base has numbers it can represent that are not representable in other bases. Every base has numbers it cannot represent that are representable in other bases.
- PaulHoule 8y agoCome on, when I say 0.03 I mean 3/100 as in "3 cents".
- recursive 8y agoYes, and when I say 1/3, I mean 0.3333333333333333333333333333333333333333333333333333... and so on. Unfortunately, I can't tell you exactly, since we're using decimal.
- jschwartzi 8y agoAs a workaround you simply approximate to a significant figure past any other values in your calculation. So in practice it doesn't really matter that there's no exact base-10 representation as a decimal because there's always an approximation that introduces no error.
- recursive 8y agoSo what's 1/3 + 1/3 + 1/3? If your answer is anything other than 1, you've introduced an error.