[cmucl-ticket] [cmucl] #65: Different results for EXPT between compiled and interpreted code (was: Different results for {{{expt}}} between compiled and interpreted code)

cmucl cmucl-devel at common-lisp.net
Thu Jan 24 04:35:39 UTC 2013


#65: Different results for EXPT between compiled and interpreted code
--------------------+-------------------------------------------------------
 Reporter:  rtoy    |       Owner:  somebody
     Type:  defect  |      Status:  new     
 Priority:  major   |   Milestone:          
Component:  Core    |     Version:  2012-12 
 Keywords:          |  
--------------------+-------------------------------------------------------
Description changed by rtoy:

Old description:

> Consider
> {{{
> (defun sqr (x)
>   (declare (type (complex double-float) x))
>   (expt x 2))
> }}}
>
> Compare the results:
> {{{
> * (sqr #c(0d0 1d0))
> #C(-1d0 0d0)
>
> * (expt #c(0d0 1d0))
> #C(-1.0d0 1.2246467991473532d-16)
> }}}
>
> The difference is caused by a deftransform for {{{expt}}} that converts
> {{{(expt x 2)}}} to {{{(* x x)}}}.
>
> Perhaps the {{{expt}}} should be modified to do the same transformation
> when the power is one of the special values in the deftransform?  (The
> deftransform handles 2, 3, 4, and 1/2.)

New description:

 Consider
 {{{
 (defun sqr (x)
   (declare (type (complex double-float) x))
   (expt x 2))
 }}}

 Compare the results:
 {{{
 * (sqr #c(0d0 1d0))
 #C(-1d0 0d0)

 * (expt #c(0d0 1d0) 2)
 #C(-1.0d0 1.2246467991473532d-16)
 }}}

 The difference is caused by a deftransform for {{{expt}}} that converts
 {{{(expt x 2)}}} to {{{(* x x)}}}.

 Perhaps the {{{expt}}} should be modified to do the same transformation
 when the power is one of the special values in the deftransform?  (The
 deftransform handles 2, 3, 4, and 1/2 and their negatives.)

--

-- 
Ticket URL: <http://trac.common-lisp.net/cmucl/ticket/65#comment:1>
cmucl <http://common-lisp.net/project/cmucl>
Cmucl is a high-performance, free Common Lisp implementation.


More information about the cmucl-ticket mailing list