From 4a71206339074980e6b22cf7f91189a038abe60e Mon Sep 17 00:00:00 2001 From: toy <toy> Date: Wed, 1 May 2002 16:31:28 +0000 Subject: [PATCH] The deftransform for expt was not correctly handling the case of a zero exponent. Bug noted by Ole Rohne, in cmucl-help. --- compiler/srctran.lisp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/compiler/srctran.lisp b/compiler/srctran.lisp index f6741ef1d..ca45f02c3 100644 --- a/compiler/srctran.lisp +++ b/compiler/srctran.lisp @@ -5,7 +5,7 @@ ;;; Carnegie Mellon University, and has been placed in the public domain. ;;; (ext:file-comment - "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/srctran.lisp,v 1.109 2002/03/11 16:52:17 toy Exp $") + "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/srctran.lisp,v 1.110 2002/05/01 16:31:28 toy Exp $") ;;; ;;; ********************************************************************** ;;; @@ -2885,7 +2885,18 @@ ;; multiplication and division for small integral powers. (unless (not-more-contagious y x) (give-up)) - (cond ((zerop val) '(float 1 x)) + (cond ((zerop val) + ;; Watch out. We need to return a 1 of the same type as + ;; X. So floats should return a floating point 1, complex + ;; numbers with float components should return a complex 1 + ;; with the desired floating-point type. For all other + ;; cases, a simple 1 is the right answer. + '(cond ((floatp x) + (float 1 x)) + ((and (complexp x) (floatp (realpart x))) + (complex (float 1 (realpart x)))) + (t + 1))) ((= val 2) '(* x x)) ((= val -2) '(/ (* x x))) ((= val 3) '(* x x x)) -- GitLab