From 38c460a09eaadc74cb820062402428b6a8572e11 Mon Sep 17 00:00:00 2001
From: toy <toy>
Date: Thu, 14 Mar 2002 21:29:42 +0000
Subject: [PATCH] Reinstate the original definition of fround (calling round)
 because we currently really need an integer result to round properly.  (oddp
 doesn't work on a float.)

---
 code/numbers.lisp | 22 ++++------------------
 1 file changed, 4 insertions(+), 18 deletions(-)

diff --git a/code/numbers.lisp b/code/numbers.lisp
index c747d57ec..b996425e6 100644
--- a/code/numbers.lisp
+++ b/code/numbers.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/numbers.lisp,v 1.40 2002/02/25 16:23:10 toy Exp $")
+  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/numbers.lisp,v 1.41 2002/03/14 21:29:42 toy Exp $")
 ;;;
 ;;; **********************************************************************
 ;;;
@@ -795,23 +795,9 @@
 
 (defun fround (number &optional (divisor 1))
   "Same as ROUND, but returns first value as a float."
-  (if (eql divisor 1)
-      (round number)
-      (multiple-value-bind (tru rem)
-	  (ftruncate number divisor)
-	(let ((thresh (/ (abs divisor) 2)))
-	  (cond ((or (> rem thresh)
-		     (and (= rem thresh) (oddp tru)))
-		 (if (minusp divisor)
-		     (values (- tru 1) (+ rem divisor))
-		     (values (+ tru 1) (- rem divisor))))
-		((let ((-thresh (- thresh)))
-		   (or (< rem -thresh)
-		       (and (= rem -thresh) (oddp tru))))
-		 (if (minusp divisor)
-		     (values (+ tru 1) (- rem divisor))
-		     (values (- tru 1) (+ rem divisor))))
-		(t (values tru rem)))))))
+  (multiple-value-bind (res rem)
+      (round number divisor)
+    (values (float res (if (floatp rem) rem 1.0)) rem)))
 
 ;;;; Comparisons:
 
-- 
GitLab