circumstances.
** optimizer for (EXPT X 0) did not work for X not of type FLOAT.
** (GCD 0 <negative-integer>) returned <negative-integer>.
+ ** LCM should return a non-negative integer.
planned incompatible changes in 0.8.x:
* (not done yet, but planned:) When the profiling interface settles
(defun two-arg-lcm (n m)
(declare (integer n m))
- (* (truncate (max n m) (gcd n m)) (min n m)))
+ (let ((m (abs m))
+ (n (abs n)))
+ (multiple-value-bind (max min)
+ (if (> m n)
+ (values m n)
+ (values n m))
+ (* (truncate max (gcd n m)) min))))
;;; Do the GCD of two integer arguments. With fixnum arguments, we use the
;;; binary GCD algorithm from Knuth's seminumerical algorithms (slightly
(= (funcall fn 3) x3))
(error "bad results for ~D" x)))))
+;;; Bugs reported by Paul Dietz:
+
;;; (GCD 0 x) must return (abs x)
(dolist (x (list -10 (* 3 most-negative-fixnum)))
(assert (= (gcd 0 x) (abs x))))
+;;; LCM returns a non-negative number
+(assert (= (lcm 4 -10) 20))
;;; checkins which aren't released. (And occasionally for internal
;;; versions, especially for internal versions off the main CVS
;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"0.8.3.35"
+"0.8.3.36"