expt: repair for non-integer power of negative inexact
If the inexact approximation of the power is an integer, then the result was a real number when it should be a complex number.
This commit is contained in:
parent
1e9d7c1d2a
commit
a88c79fd5b
|
@ -566,6 +566,10 @@
|
|||
(test 0.0f0 expt -0.9999f0 (expt 2 5000))
|
||||
(test -0.0f0 expt -0.9999f0 (add1 (expt 2 5000)))
|
||||
|
||||
(test +inf.0+inf.0i expt -0.1 -1000000000000001/3) ; inexact approx is non-integer
|
||||
(test -inf.0-inf.0i expt -0.1 -100000000000000000001/3) ; inexact approx is integer
|
||||
|
||||
|
||||
(err/rt-test (max 0 'a))
|
||||
(err/rt-test (min 0 'a))
|
||||
(err/rt-test (max 'a 0))
|
||||
|
|
|
@ -3618,6 +3618,13 @@ scheme_expt(int argc, Scheme_Object *argv[])
|
|||
return SELECT_EXPT_PRECISION(scheme_nzerof, scheme_nzerod);
|
||||
}
|
||||
}
|
||||
|
||||
if ((d < 0.0) && SCHEME_RATIONALP(e)) {
|
||||
/* The inexact approximation of a rational number might be an integer.
|
||||
Make sure we stay on the complex track: */
|
||||
return scheme_complex_power(scheme_real_to_complex(n),
|
||||
scheme_real_to_complex(e));
|
||||
}
|
||||
}
|
||||
|
||||
r = bin_expt(argv[0], e);
|
||||
|
|
Loading…
Reference in New Issue
Block a user