Correct for scaling overshoot in `ratnum->flonum'.
authorChris Hanson <org/chris-hanson/cph>
Thu, 11 Jan 1990 01:01:44 +0000 (01:01 +0000)
committerChris Hanson <org/chris-hanson/cph>
Thu, 11 Jan 1990 01:01:44 +0000 (01:01 +0000)
v7/src/runtime/arith.scm

index 66e6969c439948bf6529fb35b14eb92fae89f96a..09c6c099a896da4784b24933809922be6811d0e3 100644 (file)
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/arith.scm,v 1.12 1990/01/10 23:19:57 hal Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/arith.scm,v 1.13 1990/01/11 01:01:44 cph Exp $
 
 Copyright (c) 1989 Massachusetts Institute of Technology
 
@@ -597,14 +597,17 @@ MIT in each case. |#
                     (d (int:* d (int:quotient u g)))
                     (finish
                      (lambda (n d e)
-                       (flo:denormalize
-                        (integer->flonum
-                         (let ((g (int:gcd d u)))
-                           (int:round
-                            (int:* n (int:quotient u g))
-                            (int:quotient d g)))
-                         #b11)
-                        e))))
+                       (let ((c
+                              (lambda (n e)
+                                (flo:denormalize (integer->flonum n #b11) e)))
+                             (n
+                              (let ((g (int:gcd d u)))
+                                (int:round
+                                 (int:* n (int:quotient u g))
+                                 (int:quotient d g)))))
+                         (if (int:= n u)
+                             (c (int:quotient n 2) (int:1+ e))
+                             (c n e))))))
                 (if (int:< n d)
                     (let scale-up ((n n) (e 0))
                       (let ((n*2 (int:* n 2)))