Calculating Pi On the 4004 CPU, Intel’s First Microprocessor

These days we are blessed with multicore 64-bit monster CPUs that can calculate an entire moon mission’s worth of instructions in the blink of an eye. Once upon a time, though, the state of the art was much less capable; Intel’s first microprocessor, the 4004, was built on a humble 4-bit architecture with limited instructions. [Mark] decided calculating pi on this platform would be a good challenge. 


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


[Mark] chose to use a spigot algorithm from [Stan Wagon] and [Stanley Rabinowitz], also referred to as the “Double-Stan Method.” This algorithm only uses integer division and is rather fitting for the limitations of the 4004 chip.


Running on a real 4004 with peripheral hardware simulated inside an STM32, it spent 3 hours, 31 minutes and 13 seconds calculating 255 digits of pi, and correctly, too. As a contrast, an experiment [Mark] ran on a first-generation Xeon processor calculated 25 million digits of pi in under a second. Oh, how far we’ve come.


We’ve seen other resource-limited pi calculators before, too. If you’ve been running your own mathematical experiments, don’t hesitate to drop us a line. Just be sure to explain in clear terms if your work is full of the m ..

Support the originator by clicking the read the rest link below.