Move SFUNCTION type earlier, use it more.
[sbcl.git] / contrib / sb-mpfr / tests.lisp
blob700b996d232d4567fdcd8ae292629a08d2aecd0b
1 (defpackage "SB-MPFR-TESTS"
2 (:use "COMMON-LISP" "SB-RT"))
4 (in-package "SB-MPFR-TESTS")
6 (defun sample ()
7 (let ((sb-mpfr:*mpfr-rnd* :MPFR_RNDD))
8 (sb-mpfr:with-precision 200
9 (let ((u (sb-mpfr:coerce 1.0d0 'sb-mpfr:mpfr-float)))
10 (loop for i from 1 to 100
11 for v = u then (sb-mpfr:mul v i :MPFR_RNDU)
12 collect (sb-mpfr:div u v)
13 into vals
14 finally (return (sb-mpfr:sum (cons u vals))))))))
16 (defun sample2 ()
17 (let ((sb-mpfr:*mpfr-rnd* :MPFR_RNDD))
18 (sb-mpfr:with-precision 200
19 (let* ((u (sb-mpfr:coerce 1.0d0 'sb-mpfr:mpfr-float))
20 (s u))
21 (loop for i from 1 to 100
22 for v = u then (sb-mpfr:mul v i :MPFR_RNDU)
23 do (setf s (sb-mpfr:add s (sb-mpfr:div u v)))
24 finally (return s))))))
26 (defun sample-pi ()
27 (sb-mpfr:set-precision 400)
28 (sb-mpfr:const-pi))