[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- To: (BUG LISP) at MIT-MC
- From: KMP at MIT-MC (Kent M. Pitman)
- Date: Tue, 23 Sep 80 22:34:00 GMT
- Cc: JM at MIT-MC, ERIC at MIT-EECS, LICK at MIT-XX
- Original-date: 23 SEP 1980 1834-EDT
(DEFUN FACTORIAL (X)
(COND ((ZEROP X) 1)
(T (* X (FACTORIAL (1- X))))))
This will behave like the description of the bug report we received from
JM. The bug just stems from the fact that "*" is the fixnum-only
multiplication operator for Maclisp. It is defined to do whatever the
machine hardware integer multiply does and to not err if overflow occurs.
As a result, you experience wrap-around as your number goes out of bounds.
The solution is to use TIMES, which will be careful about overflow and
help you into the bignum range.