Lisp HUG Maillist Archive

Behavior of expt

Hi,

(expt 0 0)
=> 1

(expt 0 0.0)
=> Error: Arithmetic error in EXPT of (0 0.0): Arguments not in domain. 


Is this expected behavior?

Erik


_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html

Re: Behavior of expt

First one: (expt 0 0) => 1 appears to be correct. Second one with float exponent is disputing the meaning of “domain”. 

But according to CLHS:

When power-number is an integer 0, then the result is always the value one in the type of base-number, even if the base-number is zero (of any type). That is: 


 (expt x 0) ==  (coerce 1 (type-of x))
If power-number is a zero of any other type, then the result is also the value one, in the type of the arguments after the application of the contagion rules in Section 12.1.1.2 (Contagion in Numeric Operations), with one exception: the consequences are undefined if base-number is zero when power-number is zero and not of type integer. 

So yes, it appears to be a correct outcome in both cases….

- DM

On Nov 14, 2019, at 3:22 AM, Erik Ronström <erik.ronstrom@doremir.com> wrote:

Hi,

(expt 0 0)
=> 1

(expt 0 0.0)
=> Error: Arithmetic error in EXPT of (0 0.0): Arguments not in domain.


Is this expected behavior?

Erik


_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html

Updated at: 2020-12-10 08:29 UTC