# [plt-scheme] Numerical precision (sqrt 2)

rw wrote:
>* I am seeking a (hopefully built-in) way to decide the precision of
*>* irrational numbers. By default (PLT 4.1.5) gives:
*>*
*>* (sqrt 2) -> 1.4142135623730951
*>*
*>* I want to get an answer in (say) 50 or 100 digits precision. I am
*>* considering building a generating function for each digit of the
*>* irrational number, but I expect this to be computationally slow.
*>* Ideally, it would operate like this:
*>*
*>* (precision-take (sqrt 2) 50) -> 2^0.5 with 50 significant digits
*>*
*>* Is functionality like this already out there?
*>*
*>*
*
(define (precision-sqrt n d)
(/ (integer-sqrt (* n (expt 10 (* 2 d))))
(expt 10 d)))
(precision-sqrt 2 50)
I would also suggest you to read
http://docs.plt-scheme.org/guide/numbers.html for more understanding
about PLT's number system.
Chongkai