mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-14 08:27:34 +02:00
inexact->exact can convert non-integers when exact ratios are supported
This commit is contained in:
parent
a4bd018480
commit
7b7c2aed8e
2 changed files with 5 additions and 0 deletions
|
@ -39,6 +39,7 @@ sexp sexp_div (sexp ctx, sexp a, sexp b);
|
|||
sexp sexp_quotient (sexp ctx, sexp a, sexp b);
|
||||
sexp sexp_remainder (sexp ctx, sexp a, sexp b);
|
||||
#if SEXP_USE_RATIOS
|
||||
sexp sexp_double_to_ratio (sexp ctx, double f);
|
||||
double sexp_ratio_to_double (sexp rat);
|
||||
sexp sexp_make_ratio (sexp ctx, sexp num, sexp den);
|
||||
sexp sexp_ratio_normalize (sexp ctx, sexp rat, sexp in);
|
||||
|
|
4
vm.c
4
vm.c
|
@ -1670,7 +1670,11 @@ sexp sexp_apply (sexp ctx, sexp proc, sexp args) {
|
|||
case SEXP_OP_FLO2FIX:
|
||||
if (sexp_flonump(_ARG1)) {
|
||||
if (sexp_flonum_value(_ARG1) != trunc(sexp_flonum_value(_ARG1))) {
|
||||
#if SEXP_USE_RATIOS
|
||||
_ARG1 = sexp_double_to_ratio(ctx, sexp_flonum_value(_ARG1));
|
||||
#else
|
||||
sexp_raise("inexact->exact: not an integer", sexp_list1(ctx, _ARG1));
|
||||
#endif
|
||||
#if SEXP_USE_BIGNUMS
|
||||
} else if ((sexp_flonum_value(_ARG1) > SEXP_MAX_FIXNUM)
|
||||
|| sexp_flonum_value(_ARG1) < SEXP_MIN_FIXNUM) {
|
||||
|
|
Loading…
Add table
Reference in a new issue