## Friday, November 12, 2004

### 100,000 digits of e

In case you were wondering about the title to my little PHP rant the other day, it's *e*, the
mathematical constant dealing with natural logarithms, out to 20 decimal
places. I felt that was a good place to break it as any.

I got the value from a program I
wrote, oh, it looks to be around 1995 or so, and was based upon a
program written by Steve
Wozniak for the Apple ][ computer, and documented in a Byte Magazine article from
December 1980 (I think—the copy of the article is buried somewhere around
here, but the timeframe is close enough to track down the article if you are
truely interested). Written in 6502 Assembly and it calculated *e* out
to 100,000 digits (no more since there was no more memory in the Apple ][ to
hold the result). By following the article and the 6502 Assembly code, I
was able to rewrite it in C.

Now, when Steve Wozniak first wrote it, it took the Apple ][ a week to
calculate the result—a modern machine (okay, a 1.6GHz AMD Athalon) took
only 2½ minutes to calculate *e* to 100,000 digits (the output give the amount of memory
used, the number of digits produced (and in this case, 50,000 bytes gives
120,412 digits) and the magnitude of the result and the resultant number
itself, but without the leading 2).

Amazing the speed advances that 24 years can bring.

As for how the program works, you'll have to dig up the article and find out; I don't recall the math behind it anymore.