From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.devel Subject: Re: fix for expt bug Date: Thu, 04 Nov 2010 13:27:01 -0400 Message-ID: <87vd4duhi2.fsf@yeeloong.netris.org> References: <8762whnc4d.fsf@yeeloong.netris.org> <87r5f4l3yt.fsf@yeeloong.netris.org> <87aalrxim7.fsf@yeeloong.netris.org> <87wrouwf6b.fsf@yeeloong.netris.org> <87bp66rns2.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1288891677 7399 80.91.229.12 (4 Nov 2010 17:27:57 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 4 Nov 2010 17:27:57 +0000 (UTC) Cc: guile-devel@gnu.org To: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Nov 04 18:27:52 2010 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PE3bJ-0001gm-Du for guile-devel@m.gmane.org; Thu, 04 Nov 2010 18:27:51 +0100 Original-Received: from localhost ([127.0.0.1]:36550 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PE3bH-0004Xd-LP for guile-devel@m.gmane.org; Thu, 04 Nov 2010 13:27:47 -0400 Original-Received: from [140.186.70.92] (port=37911 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PE3bE-0004XA-QS for guile-devel@gnu.org; Thu, 04 Nov 2010 13:27:45 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PE3bD-0006YM-JL for guile-devel@gnu.org; Thu, 04 Nov 2010 13:27:44 -0400 Original-Received: from world.peace.net ([216.204.32.208]:39911) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PE3bB-0006Vz-HC; Thu, 04 Nov 2010 13:27:42 -0400 Original-Received: from ip68-9-118-38.ri.ri.cox.net ([68.9.118.38] helo=freedomincluded) by world.peace.net with esmtpa (Exim 4.69) (envelope-from ) id 1PE3an-0000T5-LD; Thu, 04 Nov 2010 13:27:18 -0400 Original-Received: from mhw by freedomincluded with local (Exim 4.69) (envelope-from ) id 1PE3aY-0006n1-4d; Thu, 04 Nov 2010 13:27:02 -0400 In-Reply-To: <87bp66rns2.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Thu, 04 Nov 2010 00:27:25 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:11117 Archived-At: ludo@gnu.org (Ludovic Court=C3=A8s) 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 =E2=80=9Cinexact number=E2=80=9D, right? No, I meant "inexact integer", for example 3.0. > However, an integer is necessarily an exact number, No, (integer? 3.0) returns #t, as it should, according to R5RS. R5RS's description of "integer?" gives this precise example, and guile's implementation agrees. > So I suspect that your patch doesn=E2=80=99t work because =E2=80=98inexac= t->exact=E2=80=99 > returns something that=E2=80=99s obviously not necessarily an integer: I'm only talking about inexact integers such as 3.0, so that (expt 2 3.0) =3D=3D> (integer-expt 2.0 3) =3D=3D> 8.0 However, I have since realized that it is not enough to convert the base to inexact; I must also convert integer-expt's result to inexact, because there is one case where making the base inexact is not enough: (expt 3 0.0) =3D=3D> (integer-expt 3.0 0) =3D=3D> 1 Though (expt 3 0.0) should reduce to 1.0. So the code needs to coerce the result of integer-expt to inexact. I am working on a patch to fix these and some other problems. Mark