Calculation of Pi on the 4004 processor, Intel’s first microprocessor

These days, we’re blessed with 64-bit multi-core monster processors capable of calculating instructions for an entire lunar mission in the blink of an eye. Once upon a time, however, the state of the art was far less capable; Intel’s first microprocessor, the 4004, was built on a humble 4-bit architecture with limited instructions. [Mark] decided to calculate pi on this platform would be a good challenge.

It’s not the easiest thing to do; a 4-bit processor cannot easily store long numbers, nor does the 4004 have native floating-point capability. AND and XOR aren’t available either, and there’s only 10,240 bits of RAM to play with. These limits have guided [Mark’s] choice of algorithm to calculate the only truly round number.

[Mark] chose to use a tap algorithm of [Stan Wagon] and [Stanley Rabinowitz], also called the “Double-Stan method”. This algorithm only uses integer division and is rather adapted to the limitations of the 4004 chip.

Running on a real 4004 with simulated peripheral hardware inside an STM32, it spent 3 hours, 31 minutes and 13 seconds calculating 255 digits of pi, and correctly too. On the other hand, an experience [Mark] running on a first-generation Xeon processor calculated 25 million digits of pi in less than a second. Oh, how far we’ve come.

We’ve seen other resource-limited pi calculators before. If you have conducted your own mathematical experiments, do not hesitate to write to us. Just be sure to explain in clear terms if your work contains the more obscure letters of the Greek alphabet!

Comments are closed.