Why can’t computers calculate decimals as floats properly?

242 views

Why can’t computers calculate decimals as floats properly?

In: 2

9 Answers

Anonymous 0 Comments

They can! You can write software to do it, using the operations supported by the computer.

There are two big differences between “proper” decimal numbers and floats: one is that floats work with binary numbers rather than decimal (base-10). That’s just a matter of building the right hardware, and we *could* certainly make computers which operated directly on base-10 numbers. It has been proposed before, but it hasn’t caught on.

The *other* difference is trickier. Computer instructions work with fixed-length data. Add a 64-bit number to a 64-bit number, for example.

And true decimals might have any length. 1.6345454234123424534524234 or 456347772234424767435234255634234235234 or whatever number you can think of. It might not fit into any specific length. So the computer can’t handle those natively in hardware. But you can still write software to deal with them.

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