Leibniz_Pi.py

David Boddie david at boddie.net
Tue Oct 15 06:21:54 EDT 2002


bokr at oz.net (Bengt Richter) wrote in message news:<aoa724$jv1$0 at 216.39.172.122>...

> BTW, I once played around with generating binary instead of decimal digits,
> which you can do by changing a couple of magic 10's to 2's in the algorithm
> (and catching the first digit for special treatment, as it will be 3 either
> way). Anyway, it provides a stream of bits that can drive interesting things
> like dots or turtle tile strokes on graphics. Of course you can do that with
> decimals or other bases too (bigger bases need a different lambda for
> the digit conversion though). Maybe I'll wrap this in a class with a digit
> list callback (like the 50 in this, or other lengths, e.g., 3 might be
> useful for watching rgb dots one by one).

It would be interesting to add an irrational number class to Python with
methods for generating approximations to whatever accuracy is desired.
I can't see an existing PEP for this at the moment, only one for rational
numbers.

-- 
David



More information about the Python-list mailing list