Today, we are blessed with multicore 64-bit monster CPUs that can compute the instructions of an entire moon mission in the blink of an eye. However, there was a time when the prior art was much less capable; Intel’s first microprocessor, the 4004, was built on a modest 4-bit architecture with limited instructions. [Mark] decided that 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, nor does the 4004 have native floating point capability. AND and XOR are also not available and there is only 10,240 bits of RAM to play with. These restrictions led [Mark’s] choice of algorithm for calculating the only really round number.
[Mark] chose to use a spigot algorithm from [Stan Wagon] and [Stanley Rabinowitz], also known as the “Double-Stan method”. This algorithm only uses integer divisions and fits reasonably well with the limitations of the 4004 chip.
Running on a real 4004 with peripherals simulated in an STM32, it spent 3 hours, 31 minutes and 13 seconds calculating 255 digits of pi, and correctly. As a contrast, an experiment [Mark] ran on a first-generation Xeon processor and calculated 25 million pi digits in less than a second. Oh, how far we’ve come.
We’ve also seen other resource-constrained pi calculators before. If you’ve done your own math experiments, don’t hesitate to drop us a line. Be sure to explain in clear terms if your work is full of the more obscure letters in the Greek alphabet!
This post Calculating Pi on the 4004 CPU, Intel’s First Microprocessor
was original published at “https://hackaday.com/2022/04/15/calculating-pi-on-the-4004-cpu-intels-first-microprocessor/”