bug-guile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (expt 2 (log 0)) hangs


From: Marius Vollmer
Subject: Re: (expt 2 (log 0)) hangs
Date: Tue, 07 Sep 2004 12:59:13 +0200
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (gnu/linux)

Kevin Ryde <address@hidden> writes:

> Thanks.  I fixed integer-expt to reject an exponent +/-inf.

Hmm, we could only allow exact integers.  That would reject +/-inf as
well.  Right now, we have

    (exact? (integer-expt 2 2.0))
    => #t

which seems wrong.

> It got there because (integer? -inf.0) => #t, which seems pretty
> wrong to me, so I changed that to #f.  That expt now goes to pow(),
> giving 0.

Making the infinities integers was done on purpose, to follow the lead
of PLT Scheme.  After all

    floor (inf) == inf   &&   ceil (inf) == inf

It would not be good to be gratuitously incompatible with PLT Scheme
here.


I propose to have integer-expt reject all inexact integers and change
expt so that it does not use it for inexact numbers.

That way, we can correctly compute things like

   (expt 2 -inf.0)
   => 0.0

   (expt 0.5 -inf.0)
   => +inf.0

[ Also, integer-expt now also works with negative exponents, but the
  docstring doesn't state this and expt could be simplyfied by
  exploiting it.
]

Opinions?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]