mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-10 22:47:33 +02:00
adjusting for roundoff errors in expt
This commit is contained in:
parent
2821bafcb6
commit
744bde8997
2 changed files with 2 additions and 2 deletions
2
eval.c
2
eval.c
|
@ -1210,7 +1210,7 @@ static sexp sexp_expt_op (sexp ctx sexp_api_params(self, n), sexp x, sexp e) {
|
||||||
else
|
else
|
||||||
return sexp_type_exception(ctx, self, SEXP_FIXNUM, e);
|
return sexp_type_exception(ctx, self, SEXP_FIXNUM, e);
|
||||||
f = pow(x1, e1);
|
f = pow(x1, e1);
|
||||||
if ((f > SEXP_MAX_FIXNUM) || (f < SEXP_MIN_FIXNUM)
|
if ((f*1000.0 > SEXP_MAX_FIXNUM) || (f*1000.0 < SEXP_MIN_FIXNUM)
|
||||||
#if SEXP_USE_FLONUMS
|
#if SEXP_USE_FLONUMS
|
||||||
|| (! sexp_fixnump(x)) || (! sexp_fixnump(e))
|
|| (! sexp_fixnump(x)) || (! sexp_fixnump(e))
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -455,7 +455,7 @@ sexp sexp_bignum_expt (sexp ctx, sexp a, sexp b) {
|
||||||
if (e & 1)
|
if (e & 1)
|
||||||
res = sexp_bignum_mul(ctx, NULL, res, acc);
|
res = sexp_bignum_mul(ctx, NULL, res, acc);
|
||||||
sexp_gc_release2(ctx);
|
sexp_gc_release2(ctx);
|
||||||
return res;
|
return sexp_bignum_normalize(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************** generic arithmetic ************************/
|
/****************** generic arithmetic ************************/
|
||||||
|
|
Loading…
Add table
Reference in a new issue