On 12 Jul 2000, Mikael Djurfeldt wrote:
> > The test for exactness if wrong here: Rationals (if supported) could
> > fulfill that predicate as well. I will apply the following patch:
> >
> > diff -u -r1.208 boot-9.scm
> > --- boot-9.scm 2000/07/01 17:01:22 1.208
> > +++ boot-9.scm 2000/07/12 07:23:07
> > @@ -793,7 +793,7 @@
> > (define expt
> > (let ((integer-expt integer-expt))
> > (lambda (z1 z2)
> > - (cond ((exact? z2)
> > + (cond ((and (integer? z2) (>= z2 0))
> > (integer-expt z1 z2))
> > ((and (real? z2) (real? z1) (>= z1 0))
> > ($expt z1 z2))
>
> Did you check with R5RS that it is OK to return an inexact in the case
> of exact negative exponent? (I presume it ius.)
I did not think about that. However: In which cases of exact negative
exponents can the result be an exact value at all?
-> exponent is a negative integer --> result could be a rational if those
were supported. This could be handled nicely:
cond ((and (integer? z2) (< z2 0)) (/ 1 (integer-expt z1 (- z2))))
Shall I add this special case to expt?
-> exponent is a negative rational --> result will be a real, except for
the rare cases that the square root (or whatever root) can be solved
exactly. I don't know how to handle this nicely.
In any case, this example makes it clear that there can not be a demand
for an exact result, even if the exponent is exact.
Best regards
Dirk