Why can’t computers calculate decimals as floats properly?

234 views

Why can’t computers calculate decimals as floats properly?

In: 2

9 Answers

Anonymous 0 Comments

A lot of the issues comes from the base conversion.
Imagine instead of converting from base 10 to base 2, we were converting to base 9.

Converting integers is easy, e.g. 11 becomes 12, 23 becomes 25 etc. Fractions is harder though. 0.5==1/2 becomes 0.45, 1/3 becomes 0.3, but what should 0.3 become? The best you can do is approximate.

The same is happening in the conversion of our decimal numbers to binary, we have to come up with an approximation. It’s this approximation that introduces the errors you see

You are viewing 1 out of 9 answers, click here to view all answers.