This is the mail archive of the guile@cygnus.com mailing list for the guile project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
I think the following function does a reasonable
job of dividing two bignums and returning a floating
point result. It doesn't look as though it
should be too hard to render into C, or to extend
to sqrt and log.
A conservative test for whether something like this is necessary
should also be fairly quick, just look at the number of big digits in
each of the arguments.
(define *float-expt* 1024) ;; this depends on float representation.
;; probably there should be some way of
;; determining this from the Scheme level.
(define (big-i/ num den)
(let* ((nf (max 0
(- (max (integer-length num)
(integer-length den))
*float-expt*)))
(fact/2 (ash 1 (- nf 1))))
(/ (exact->inexact (ash (+ num fact/2) (- nf)))
(exact->inexact (ash (+ den fact/2) (- nf))))))