mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-18 21:29:19 +02:00
Fix bug: sexp_read_number can't parse a/b@c-style number correctly.
This commit is contained in:
parent
dde5f6c88d
commit
35281cf28e
1 changed files with 6 additions and 3 deletions
9
sexp.c
9
sexp.c
|
@ -3020,12 +3020,15 @@ sexp sexp_read_number (sexp ctx, sexp in, int base, int exactp) {
|
|||
sexp_complex_imag(den) = res;
|
||||
#if SEXP_USE_MATH
|
||||
} else if (sexp_flonump(sexp_complex_real(den))) { /* assume polar */
|
||||
rho = sqrt(sexp_flonum_value(sexp_complex_real(den)) *
|
||||
sexp_flonum_value(sexp_complex_real(den)) +
|
||||
sexp_to_double(ctx, sexp_complex_imag(den)) +
|
||||
double real = sexp_flonum_value(sexp_complex_real(den));
|
||||
rho = sqrt(real * real +
|
||||
sexp_to_double(ctx, sexp_complex_imag(den)) *
|
||||
sexp_to_double(ctx, sexp_complex_imag(den)));
|
||||
theta = atan(sexp_to_double(ctx, sexp_complex_imag(den)) /
|
||||
sexp_flonum_value(sexp_complex_real(den)));
|
||||
if (real < 0) {
|
||||
theta += M_PI;
|
||||
}
|
||||
rho = sexp_to_double(ctx, sexp_div(ctx, res, sexp_make_fixnum((sexp_sint_t)round(rho))));
|
||||
sexp_complex_real(den) = sexp_make_flonum(ctx, rho * cos(theta));
|
||||
sexp_complex_imag(den) = sexp_make_flonum(ctx, rho * sin(theta));
|
||||
|
|
Loading…
Add table
Reference in a new issue