[Top][All Lists]

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

Re: fix for expt bug

From: Mark H Weaver
Subject: Re: fix for expt bug
Date: Tue, 02 Nov 2010 15:19:03 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

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

* Test that (expt -1 0.5) is loosely equal to +i.
  (I believe this would have failed with your second patch)


reply via email to

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