Why our computers are not good at computing

Raghav Ojha
2 min readJul 3, 2021

I always thought computers were better at math and people until I tried to add 0.1 to 0.2 in Javascript (which is just a programming language) and got an answer of 0.3000000004.

What the hell! So I figured it was a bug and tried the same thing in Python but it also gave me the same wrong answer. Then I discovered that these languages aren’t actually broken they just do floating-point arithmetic.

Computers have a limited amount of memory and need to make a trade-off between range and precision. In best cases, all numbers must be stored within 64 bits. That means we can have integers accurate up to 15 digits and a max of 17 numbers after the decimal point. It’s called a floating-point because there are no fixed number of digits before or after the decimal point. This allows it to represent a wide range of numbers both big and small.

The problem is that computers use a base 2 system binary while humans use a base 10 system that leads to rounding errors when all the memory has been used up and that’s why your computer sucks at math.

Here is another example you can try out in your calculator

Now if you really want to go deep in the math part of this here are some resources you can check out:

--

--