mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-14 08:27:34 +02:00
Fixing some corner cases with mixed rational/complex notation.
This commit is contained in:
parent
d45ecf42ca
commit
b101e5c585
1 changed files with 9 additions and 5 deletions
14
sexp.c
14
sexp.c
|
@ -2394,12 +2394,15 @@ sexp sexp_read_number (sexp ctx, sexp in, int base) {
|
||||||
res = sexp_make_fixnum(negativep ? -val : val);
|
res = sexp_make_fixnum(negativep ? -val : val);
|
||||||
if (sexp_complex_real(den) == SEXP_ZERO) {
|
if (sexp_complex_real(den) == SEXP_ZERO) {
|
||||||
res = sexp_make_ratio(ctx, res, sexp_complex_imag(den));
|
res = sexp_make_ratio(ctx, res, sexp_complex_imag(den));
|
||||||
sexp_complex_imag(den) = sexp_ratio_normalize(ctx, res, in);
|
res = sexp_ratio_normalize(ctx, res, in);
|
||||||
|
sexp_complex_imag(den) = res;
|
||||||
} else {
|
} else {
|
||||||
res = sexp_make_ratio(ctx, res, sexp_complex_real(den));
|
res = sexp_make_ratio(ctx, res, sexp_complex_real(den));
|
||||||
sexp_complex_real(den) = sexp_ratio_normalize(ctx, res, in);
|
res = sexp_ratio_normalize(ctx, res, in);
|
||||||
|
sexp_complex_real(den) = res;
|
||||||
}
|
}
|
||||||
res = den;
|
if (!sexp_exceptionp(res))
|
||||||
|
res = den;
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
do {
|
do {
|
||||||
|
@ -2407,8 +2410,9 @@ sexp sexp_read_number (sexp ctx, sexp in, int base) {
|
||||||
res = sexp_ratio_normalize(ctx, res, in);
|
res = sexp_ratio_normalize(ctx, res, in);
|
||||||
} while (0);
|
} while (0);
|
||||||
#else
|
#else
|
||||||
res = sexp_make_flonum(ctx, (double)(negativep ? -val : val)
|
if (!sexp_exceptionp(res))
|
||||||
/ (double)sexp_unbox_fixnum(den));
|
res = sexp_make_flonum(ctx, (double)(negativep ? -val : val)
|
||||||
|
/ (double)sexp_unbox_fixnum(den));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
sexp_gc_release2(ctx);
|
sexp_gc_release2(ctx);
|
||||||
|
|
Loading…
Add table
Reference in a new issue