`expt' repair, again

Previous repair wasn't general enough; negative powers can also
go wrong.
This commit is contained in:
Matthew Flatt 2013-01-01 18:05:37 -07:00
parent 678451f8c4
commit 3c5135fc7a
2 changed files with 4 additions and 1 deletions

View File

@ -552,6 +552,8 @@
(test -0.0 expt -0.1 10000000000001.0)
(test 0.0 expt -0.0 10000000000000.0)
(test -0.0 expt -0.0 10000000000001.0)
(test 0.0 expt -10.0 -10000000000000.0)
(test -0.0 expt -10.0 -10000000000001.0)
(err/rt-test (max 0 'a))
(err/rt-test (min 0 'a))

View File

@ -2732,8 +2732,9 @@ static double sch_pow(double x, double y)
double r;
r = protected_pow(x, y);
if ((r == 0.0) && !minus_zero_p(r)) {
/* check large odd power of a small negative number,
/* check zero result of a odd power of a negative number,
which some libraries get wrong for some reason */
if (y < 0) y = -y;
if ((x < 0) && (fmod(y, 2.0) == 1.0)) {
r = scheme_floating_point_nzero;
}