adjusting for roundoff errors in expt

This commit is contained in:
Alex Shinn 2011-05-30 23:22:08 +09:00
parent 2821bafcb6
commit 744bde8997
2 changed files with 2 additions and 2 deletions

2
eval.c
View file

@ -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

View file

@ -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 ************************/