# infinite (fractional) precision

**Jerzy Karczmarczuk
**
karczma@info.unicaen.fr

*Thu, 10 Oct 2002 10:55:05 +0200*

Ketil Z. Malde wrote:
>* It seems one could easily (I'll get back to that in a moment)
*>* calculate the fractional part of numbers lazily, generating the needed
*>* precision, and nothing more. Does any such implementation exist in
*>* Haskell?
*>*
*>* I realize it's probably far from trivial, e.g. comparing two equal
*>* numbers could easily not terminate, and memory exhaustion would
*>* probably arise in many other cases.
*>*
*>* So, if such implementations exist, how does one deal with these
*>* issues? Is it indeed possible to make this useful in practice?
*
Well, I implemented such a stuff for fun. Look here:
http://users.info.unicaen.fr/~karczma/arpap/lazypi.ps.gz
This shows how to implement Bailey-Borwein-Plouffe formula for PI,
using lazy hexadec. fractions, and converting them to decimal. This
is a crazy idea, with algorithms which are partly co-recursive, and
partly recursive, borrowing the carry from the non-existing yet
future. It could be done in a safer way, but I repeat that I did it
for sheer joy. Perhaps one day I will return to it, unless somebody
does it first.
Jerzy Karczmarczuk