# How do calculators handle $\pi$?

When the calculator displays the digits of $\pi$, how does it arrive at that answer? Also, at what digit does the approximation of $\pi$ stop at?

-
I'd imagine it depends on the calculator. – Zev Chonoles May 1 '12 at 0:39
The simple approach would be as a stored constant. Need it anyway for radian/degree. – André Nicolas May 1 '12 at 0:43
Storing a constant like $\pi$ to some fixed precision is not really much of a technological feat. You might be interested in some more computational details, such as how a typical calculator computes inverse trigonometric functions via CORDIC routines. – hardmath May 1 '12 at 0:45
No number is irrational on a calculator. – Gerry Myerson May 1 '12 at 0:49
No number is irrational on anything that uses floating-point arithmetic, period. – J. M. May 1 '12 at 1:12

I'm not an expert in calculators, but here's my understanding: The calculator doesn't calculate $\pi$. It has a numerical approximation programmed in, up to some degree of precision which is almost certainly more than the number of decimal places that fit in the display. Then it treats $\pi$ like any rational constant. If you want to see how far your calculator goes, here's what you can do:

First, enter $\pi$ into your calculator. Subtract 3. Multiply by 10. Subtract 1. Multiply by 10. Subtract 4, multiply by 10, subtract 1, multiply by 10, etc, getting rid of more and more digits. Eventually you'll run out of digits, get 0, or hit some other other sort of error. If you keep track of how many steps this takes, you'll find out how many digits of $\pi$ your calculator has "memorized."

-
My guess is between 9 and 15. I like this experiment. +1 – mixedmath May 1 '12 at 1:04
Indeed, constants in most calculators are cached and not computed. To use the TI-83 Plus as an example: try π-3.1415926. Actually, that makes for a slightly more efficient technique than Brett's: output the constant, note how many digits are displayed, and subtract from the constant an approximation from the digits displayed. Note how tiny the result is and how many digits are displayed. – J. M. May 1 '12 at 1:11

There's a difference between idealized mathematics and the real world calculations which require definite answers of some precision (significant digits), $\pi$ is not only irrational, it is transcedental. The computer resoloves down to a $n$-bit approximation, which is mostly impeded only by register size and the actual design of the microprocessor that powers it. It is simply a constant floating point value of varying bit-depth and is treated as such.

You can do lots of clever tricks and processing, creating huge-digit numbers which can be intrepreted by the software in terms of multiple bytes banded together ( even though it crosses register size ). But at the end of the day, every attempt to have $\pi$ naturally in the system, as an irrational and transcendental constant it is, is impossible. Computers are fundamentally deterministic and finite.

The precision varies from financial calculators, home calculators to scientific calculators. Also, defer back to hardmath's comment, CORDIC routines are interesting when the given implementation of a calculator doesn't have a hardware multiplier.

In the end: It is represented as a finite constant approximation of varying bit-depth depending on the platform it is implemented on and stored in the varying size ROM. Example, iPhone's Calculator PI constant is at around ~17 digits (bear in mind that the architecture of the iPhone is much more complex than a calculator and the representation of $\pi$ could be a lot better if you implemented it yourself using clever programming).

-
One question, how do you express a some number of decimal digits in terms of bits? – Fractal Resurgence May 1 '12 at 1:22