How Do Calculators Store Large Numbers

When you input the largest number your calculator can handle, and divide 1 by that number, you will get 0. Yes, you can get 0 from division in a budget scientific calculator. Let me explain how and why.

How Do Calculators Store Large Numbers

When you input the largest number your calculator  can handle, and divide 1 by that number, you will get 0. Yes, you can get 0 from division with a budget scientific calculator. Let me explain how and why.

Replicating the observation

For the record, my calculator is the CASIO fx-991EX, your calculator might behave differently.

First, apply a large exponent to Euler's number and keep trying until you hit an error. Then bring it down a little and repeat. For me, that exponent is 230.2585092994 and the number is 9.999999999x10^99.  Then, divide that number by 0.

\[e^{230.2585092994} = 9.999999999\times 10^{99}\]

Getting the largest possible value

\[{1\over ans} = 0\]

Dividing the number by the largest possible value

Is the Math Possible?

If you do not understand limits, skip over this section.

Let us consider the following:

\[ \lim_{x \to \infty^{+}} {1 \over x} = 0 \]

\[ \lim_{x \to 0^{+}} {1 \over x} = \infty^{+} \]

However, the exponential number we used is nowhere near positive infinity. So the result is wrong. In order words, the math is possible, but our calculations should not have given us 0. The calculator did not calculate the answer using limits.

To explain what happened within the calculator, let's talk about scientific notation.

Scientific Notation Explained

9.999999999 x 10^99 is a format known as scientific notation. You can adjust its accuracy by placing more decimal places in its coefficient. You can also change its scale (size of numbers supported) by increasing its exponent. This way, we can optimize our number for accuracy or scale as our addressable memory see fit.

Storing and Displaying Large Values in a Calculator

The exponent used earlier might appear to be the largest number before it will overflow (causing an error). That is not true, but we are very close to the largest possible number the calculator can handle.

We can increase the exponent by adding more decimal places at the back. The calculator rounds off the actual amount before displaying it to us, because there is not enough space. But eventually, the number will be so large that scientific notation will lose accuracy, without showing errors. Let me demonstrate.

I have 2 numbers of slightly different exponent that shows the same output.

The exponent is 230.258509299404, focus on the last few digits
I've added two 9s at the back

Now, is this the display limitation of a calculator, or is it storing these 2 numbers as the same scientific notation?

After subtracting the larger number from the smaller, the result is 0. This shows that they are the scientific notation stored in memory. Which means their accuracy is compromised to compensate for their scale.

I get zero when I minus them

It all makes sense, The original number is stored as a huge scientific notation. When 1 is divided by it, the answer will be very very small, extremely close to zero, the calculator loses accuracy at such a small number, and thus rounds off to 0.


References

Scientific Notation
https://en.wikipedia.org/wiki/Scientific_notation#Normalized_notation


Photo by Lum3n.com from Pexels