guile-devel
[Top][All Lists]
Advanced

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

Re: fix for expt bug


From: Ludovic Courtès
Subject: Re: fix for expt bug
Date: Thu, 04 Nov 2010 00:27:25 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

Hi Mark,

Mark H Weaver <address@hidden> writes:

> I just realized that there is a better way to fix these bugs.  We don't
> need a new top-level case in expt after all.  Instead, we generalize the
> scm_integer_expt case to support inexact integer exponents.

You mean “inexact number”, right?

The doc for ‘integer-expt’ makes the same mistake:

  "Return @var{n} raised to the power @var{k}.  @var{k} must be an\n"
  "exact integer, @var{n} can be any number.\n"

However, an integer is necessarily an exact number, whereas the converse
isn’t true:

--8<---------------cut here---------------start------------->8---
scheme@(guile-user) [25]> (exact? 2/3)
$4 = #t
scheme@(guile-user) [25]> (integer? 2/3)
$5 = #f
--8<---------------cut here---------------end--------------->8---

In actuality, ‘integer-expt’ expects K to be an integer (fixnum or
bignum).

So I suspect that your patch doesn’t work because ‘inexact->exact’
returns something that’s obviously not necessarily an integer:

--8<---------------cut here---------------start------------->8---
scheme@(guile-user) [25]> (inexact->exact 2.3)
$6 = 2589569785738035/1125899906842624
--8<---------------cut here---------------end--------------->8---

Does that make sense?

Thanks,
Ludo’.




reply via email to

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