[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

MCL floating point bug?



I am having some problems with MCL 2.0.1 running on a Centris 610
w/o FPU.  This problem does not occur on our Quadra 800 or MAC II.

The problem is that I am getting incorrect results from a math calculation.

The offending code is below.

The problem occurs with the calculation of delta-theta.

When left-speed = -10 and right-speed = 10
delta-theta is correctly calced at about 0.008.

When left-speed = 10 and right-speed = -10
delta-theta should be -0.008
but the Centris 610 gives a result of very near -0.0.

Any thoughts?

Thanks
Bob


(let 
	((left-speed 10)	
	(right-speed -10)	
	(width 12))
(multiple-value-bind (delta-x delta-y delta-theta)
     (cond ((and (zerop left) (zerop right)) (values 0 0 0))
	   ((= left right)
	    (let ((amount (* 0.05 left)))
	      (values (* amount (cos theta)) (* amount (sin theta)) 0)))
	   (t (let* ((c (cond ((zerop left) (- width))
			      ((zerop right) width)
			      (t (let ((rho (/ right left)))
				   (* width (/ (+ rho 1.0) (- 1.0 rho)))))))
		     (sgn (if (<= c 0)
			      (if (> right 0) 1 -1)
			    (if (> left 0) -1 1)))
;;here is the offending code
		     (delta-theta (* sgn 
				     #.(/ (* 0.6 pi) 180.0)
				     (abs (/ (if (zerop right) left right)
					     (- width c)))))

(format t "~%delta-theta = ~A" delta-theta)
		     (new-theta (+ delta-theta theta)))
		(values (* c (- (cos theta) (cos new-theta)))
			(* c (- (sin theta) (sin new-theta)))
			(sr-pi-rangify delta-theta)))))))