maxima-bugs

 [Maxima-bugs] [ maxima-Bugs-618280 ] entier(-1.0)==(fix -1.0) = -2 (!!!) FIX From: - 2002-12-26 17:56:23 ```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 (!!!) FIX 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))))) ---------------------------------------------------------------------- Comment By: Stavros Macrakis (macrakis) Date: 2002-10-04 09:29 Message: Logged In: YES user_id=588346 ...or this way (simple Common Lisp): (defun fix (n) (values (floor n))) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=618280&group_id=4933 ```
 [Maxima-bugs] [ maxima-Bugs-618280 ] entier(-1.0)==(fix -1.0) = -2 (!!!) FIX From: SourceForge.net - 2005-08-22 03:43:38 ```Bugs item #618280, was opened at 2002-10-03 16:10 Message generated for change (Comment added) made by robert_dodier You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=618280&group_id=4933 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. >Category: Lisp Core Group: None >Status: Closed >Resolution: Fixed Priority: 5 Submitted By: Stavros Macrakis (macrakis) Assigned to: Nobody/Anonymous (nobody) Summary: entier(-1.0)==(fix -1.0) = -2 (!!!) FIX 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))))) ---------------------------------------------------------------------- >Comment By: Robert Dodier (robert_dodier) Date: 2005-08-21 21:43 Message: Logged In: YES user_id=501686 src/clmacs.lisp patched with (defun fix (n) (values (floor n))) as suggested below. Compiles OK w/ gcl 2.6.6 and clisp 2.33, in each case run_testsuite reports no unexpected errors. ---------------------------------------------------------------------- Comment By: Stavros Macrakis (macrakis) Date: 2002-10-04 07:29 Message: Logged In: YES user_id=588346 ...or this way (simple Common Lisp): (defun fix (n) (values (floor n))) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=618280&group_id=4933 ```