/[gcl]/gcl/ansi-tests/numbers-aux.lsp
ViewVC logotype

Diff of /gcl/ansi-tests/numbers-aux.lsp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by pfdietz, Sat Aug 23 13:45:25 2003 UTC revision 1.8 by pfdietz, Sun Aug 31 02:18:49 2003 UTC
# Line 206  Line 206 
206      (long-float long-float-negative-epsilon)      (long-float long-float-negative-epsilon)
207      (rational 0)))      (rational 0)))
208    
209    ;;; Compute the number of digits that can be added to 1.0 in the appropriate
210    ;;; float type, a rational representation of the smallest radix^(-k) s.t.
211    ;;; 1.0 + radix^(-k) /= 1.0, and the float representation of that value.
212    ;;; Note that this will in general be > <float-type>-epsilon.
213    
214    (defun find-epsilon (x)
215      (assert (floatp x))
216      (let* ((one (float 1 x))
217             (radix (float-radix one))
218             (eps (/ 1 radix)))
219        (loop
220         for next-eps = (/ eps radix)
221         for i from 1
222         until (eql one (+ one next-eps))
223         do (setq eps next-eps)
224         finally (return (values i eps (float eps one))))))

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26