[Bese-devel] Bug in arnesi parse-float

Eugene Tyurin etyurin at comcast.net
Sat Feb 5 02:48:50 UTC 2005


There's a bug in parse-float when parsing negative numbers.  Here's my 
fix:

--- /Users/gene/tmp/numbers-ent.lisp    2005-02-04 21:42:49.000000000 
-0500
+++ libs/arnesi/src/numbers.lisp        2005-02-02 23:05:15.000000000 
-0500
@@ -20,10 +20,8 @@
                   mantissa (parse-integer string :start (1+ it) :end 
end :radix radix))
             (if (zerop mantissa)
                 (float whole-part)
-              (let ((mantissa-float (/ mantissa (expt radix (1+ (floor 
(log mantissa radix)))))))
-                (if (char= #\- (elt string 0))
-                    (- whole-part mantissa-float)
-                    (+ whole-part mantissa-float)) )))
+               (+ whole-part
+                  (/ mantissa (expt radix (1+ (floor (log mantissa 
radix))))))))
           (parse-integer string :start start :end end :radix radix))))

  (define-modify-macro mulf (delta) * "SETF NUM to the result of (* NUM 
B).")

Can't use simple (> 0 whole-part) test, because that would not work for 
negatives between 0 and -1.

--ET.




More information about the bese-devel mailing list