fix `expt' on small negative number and large positive odd
The pow() function apparently gets it wrong on some platforms. Closes PR 13391
This commit is contained in:
parent
974350472c
commit
07d5a9e385
|
@ -406,6 +406,7 @@
|
|||
|
||||
(define focus-here? #f)
|
||||
(define/override (on-focus? on?)
|
||||
(unless on? (on-menu-click))
|
||||
(on-focus-child on?)
|
||||
(cond
|
||||
[on?
|
||||
|
|
|
@ -548,6 +548,10 @@
|
|||
(test (- (expt 5 29)) min (- (expt 5 29)) (expt 5 27))
|
||||
(test (- (expt 5 29)) min (- (expt 5 27)) (- (expt 5 29)))
|
||||
(test (- (expt 5 29)) min (- (expt 5 29)) (- (expt 5 27)))
|
||||
(test 0.0 expt -0.1 10000000000000.0)
|
||||
(test -0.0 expt -0.1 10000000000001.0)
|
||||
(test 0.0 expt -0.0 10000000000000.0)
|
||||
(test -0.0 expt -0.0 10000000000001.0)
|
||||
|
||||
(err/rt-test (max 0 'a))
|
||||
(err/rt-test (min 0 'a))
|
||||
|
|
|
@ -2729,7 +2729,16 @@ static double sch_pow(double x, double y)
|
|||
return scheme_infinity_val;
|
||||
}
|
||||
} else {
|
||||
return protected_pow(x, 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,
|
||||
which some libraries get wrong for some reason */
|
||||
if ((x < 0) && (fmod(y, 2.0) == 1.0)) {
|
||||
r = scheme_floating_point_nzero;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue
Block a user