mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 13:49:17 +02:00
Fixing exact-integer-sqrt on linux.
This commit is contained in:
parent
40391a9ad3
commit
daa2d96ff0
1 changed files with 6 additions and 2 deletions
8
bignum.c
8
bignum.c
|
@ -636,9 +636,13 @@ sexp sexp_bignum_sqrt (sexp ctx, sexp a, sexp* rem_out) {
|
||||||
res = sexp_quotient(ctx, res, SEXP_TWO);
|
res = sexp_quotient(ctx, res, SEXP_TWO);
|
||||||
goto loop;
|
goto loop;
|
||||||
}
|
}
|
||||||
/* convert back to inexact if non-zero remainder */
|
} else {
|
||||||
*rem_out = sexp_bignum_normalize(rem);
|
if (sexp_flonump(res))
|
||||||
|
res = sexp_bignum_normalize(sexp_double_to_bignum(ctx, sexp_flonum_value(res)));
|
||||||
|
tmp = sexp_mul(ctx, res, res);
|
||||||
|
rem = sexp_sub(ctx, a, tmp);
|
||||||
}
|
}
|
||||||
|
*rem_out = sexp_bignum_normalize(rem);
|
||||||
sexp_gc_release4(ctx);
|
sexp_gc_release4(ctx);
|
||||||
return sexp_bignum_normalize(res);
|
return sexp_bignum_normalize(res);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue