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)))))) |