From f409569dfeb746145f0ac6054eca4fe76932376b Mon Sep 17 00:00:00 2001 From: dtc <dtc> Date: Fri, 19 Nov 1999 15:12:36 +0000 Subject: [PATCH] Fix divide-by-zero bug in rationalize (rationalize 5.964664720239993d-15) found by Akira Kurihara. The bug was caused by (- xx (float a x)) eventually becoming zero; an extra test has been added to exit the do loop when this is true. From Raymond Toy. --- code/float.lisp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/code/float.lisp b/code/float.lisp index 28ec73fe3..5cb3f302a 100644 --- a/code/float.lisp +++ b/code/float.lisp @@ -5,7 +5,7 @@ ;;; Carnegie Mellon University, and has been placed in the public domain. ;;; (ext:file-comment - "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/float.lisp,v 1.19 1999/11/11 14:46:25 dtc Exp $") + "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/float.lisp,v 1.20 1999/11/19 15:12:36 dtc Exp $") ;;; ;;; ********************************************************************** ;;; @@ -1102,11 +1102,12 @@ rounding modes & do ieee round-to-integer. (den 1 (+ (* a den) oden)) (onum 1 num) (oden 0 den)) - ((and (not (zerop den)) - (not (> (abs (/ (- x (/ (float num x) - (float den x))) - x)) - eps))) + ((or (= xx (float a x)) + (and (not (zerop den)) + (not (> (abs (/ (- x (/ (float num x) + (float den x))) + x)) + eps)))) (integer-/-integer num den)) (declare ((dispatch-type x) xx))))))) ((rational) x))) -- GitLab