Why can’t computers calculate decimals as floats properly?

228 views

Why can’t computers calculate decimals as floats properly?

In: 2

9 Answers

Anonymous 0 Comments

Computers work in binary, also known as base-2. So representing 1/2, 1/4 or even 3/64 can be done very accurately.

Problem is 10 is five times two (10 = 5 * 2). So to represent 1/10 accurately you need to store data in base-10. Any other base cannot store this fraction correctly.

To tag along what /r/pocok5 said – if a computer operated in trinary (base-3) it could represent 1/3 perfectly.

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