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: Tue, 02 Nov 2010 15:19:03 -0400 Message-ID: <87fwvjy1nc.fsf@yeeloong.netris.org> References: <8762whnc4d.fsf@yeeloong.netris.org> <87r5f4l3yt.fsf@yeeloong.netris.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1288727330 27804 80.91.229.12 (2 Nov 2010 19:48:50 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 2 Nov 2010 19:48:50 +0000 (UTC) Cc: guile-devel To: Ramakrishnan Muthukrishnan Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Nov 02 20:48:43 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 1PDMqW-0008HQ-Ci for guile-devel@m.gmane.org; Tue, 02 Nov 2010 20:48:43 +0100 Original-Received: from localhost ([127.0.0.1]:52670 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PDMqT-0002nE-Py for guile-devel@m.gmane.org; Tue, 02 Nov 2010 15:48:37 -0400 Original-Received: from [140.186.70.92] (port=55323 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PDMm9-0006qV-El for guile-devel@gnu.org; Tue, 02 Nov 2010 15:44:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PDMNy-0008JU-Tm for guile-devel@gnu.org; Tue, 02 Nov 2010 15:19:11 -0400 Original-Received: from world.peace.net ([216.204.32.208]:51135) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PDMNy-0008JI-QT for guile-devel@gnu.org; Tue, 02 Nov 2010 15:19:10 -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 1PDMNt-0006Jz-RN; Tue, 02 Nov 2010 15:19:05 -0400 Original-Received: from mhw by freedomincluded with local (Exim 4.69) (envelope-from ) id 1PDMNs-0002Ne-C6; Tue, 02 Nov 2010 15:19:04 -0400 In-Reply-To: (Ramakrishnan Muthukrishnan's message of "Tue, 2 Nov 2010 11:06:06 +0530") 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:11101 Archived-At: Hi Ramakrishnan, The code in your latest patch looks good to me, though the commit message has some problems, and I'd add more test cases: > * libguile/numbers.c: If base is negative, expt needs to find > -x^n = (-1^n) * (|x|^n). We find x^n and then if n is odd, we > also multiply the result with -1. These changes apply only for > cases where n is an integer. In the equation above, -x^n parses as -(x^n), but it should be (-x)^n. Same problem with (-1^n). Also, the absolute value should be removed. It is superfluous for the case you are handling (x>0), and for other cases it is erroneous. The equation above should be: (-x)^n = (-1)^n * x^n Also, I would add a couple more test cases: * Test the case from Ludovic's original bug report: (expt -2742638075.5 2) should loosely equal 7.52206361318235e18 * Test that (expt -1 0.5) is loosely equal to +i. (I believe this would have failed with your second patch) Thanks, Mark