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
8
sexp.c
8
sexp.c
|
@ -2394,11 +2394,14 @@ sexp sexp_read_number (sexp ctx, sexp in, int base) {
|
|||
res = sexp_make_fixnum(negativep ? -val : val);
|
||||
if (sexp_complex_real(den) == SEXP_ZERO) {
|
||||
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 {
|
||||
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;
|
||||
}
|
||||
if (!sexp_exceptionp(res))
|
||||
res = den;
|
||||
} else
|
||||
#endif
|
||||
|
@ -2407,6 +2410,7 @@ sexp sexp_read_number (sexp ctx, sexp in, int base) {
|
|||
res = sexp_ratio_normalize(ctx, res, in);
|
||||
} while (0);
|
||||
#else
|
||||
if (!sexp_exceptionp(res))
|
||||
res = sexp_make_flonum(ctx, (double)(negativep ? -val : val)
|
||||
/ (double)sexp_unbox_fixnum(den));
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue