From: <no...@so...> - 2002-10-03 22:10:28
|
Bugs item #618280, was opened at 2002-10-03 18:10 You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=618280&group_id=4933 Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Stavros Macrakis (macrakis) Assigned to: Nobody/Anonymous (nobody) Summary: entier(-1.0)==(fix -1.0) = -2 (!!!) Initial Comment: Entier(-1) = -1 (correct) Entier(-1.0) = -2 (!!!!) The problem comes from the Fix function in clmacs. It should be rewritten this way (the simple, clean, possibly a tiny bit inefficient way): (defun fix (n) (cond ((integerp n) n) ((< n 0) (cond ((= n (truncate n)) (truncate n)) (t (- (truncate n) 1)))) (t (values (truncate n))))) or this way (the old-fashioned dirty way): (defun fix (n) (cond ((integerp n) n) ((< n 0) (cond ((= n (setq n (truncate n))) n) (t (- n 1)))) (t (values (truncate n))))) or this way (the new-fangled multiple return value way): (defun fix (n) (cond ((integerp n) n) ((< n 0) (multiple-value-bind (tr rem) (truncate n) (cond ((= rem 0) tr) (t (- tr 1))))) (t (values (truncate n))))) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=618280&group_id=4933 |