mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 05:39:18 +02:00
Zero angle polars are real. Fixes issue #329.
This commit is contained in:
parent
64b8e5f8a3
commit
2a05db5382
2 changed files with 9 additions and 0 deletions
2
eval.c
2
eval.c
|
@ -1778,6 +1778,8 @@ sexp sexp_inexact_to_exact (sexp ctx, sexp self, sexp_sint_t n, sexp z) {
|
|||
res = sexp_make_complex(ctx, SEXP_ZERO, SEXP_ZERO);
|
||||
sexp_complex_real(res) = sexp_inexact_to_exact(ctx, self, 1, sexp_complex_real(z));
|
||||
sexp_complex_imag(res) = sexp_inexact_to_exact(ctx, self, 1, sexp_complex_imag(z));
|
||||
if (sexp_complex_imag(res) == SEXP_ZERO)
|
||||
res = sexp_complex_real(res);
|
||||
sexp_gc_release1(ctx);
|
||||
}
|
||||
#endif
|
||||
|
|
7
sexp.c
7
sexp.c
|
@ -2357,6 +2357,8 @@ sexp sexp_read_polar_tail (sexp ctx, sexp in, sexp magnitude) {
|
|||
res = theta;
|
||||
} else if (sexp_complexp(theta) || !sexp_numberp(theta)) {
|
||||
res = sexp_read_error(ctx, "invalid polar numeric syntax", theta, in);
|
||||
} else if (theta == SEXP_ZERO) {
|
||||
res = magnitude;
|
||||
} else {
|
||||
res = sexp_make_complex(ctx, SEXP_ZERO, SEXP_ZERO);
|
||||
sexp_complex_real(res) = sexp_cos(ctx, NULL, 1, theta);
|
||||
|
@ -2828,6 +2830,11 @@ sexp sexp_read_raw (sexp ctx, sexp in, sexp *shares) {
|
|||
&& (isnan(sexp_flonum_value(res)) || isinf(sexp_flonum_value(res))))
|
||||
res = sexp_read_error(ctx, "can't convert non-finite flonum to exact", res, in);
|
||||
else
|
||||
#endif
|
||||
#if SEXP_USE_COMPLEX
|
||||
if (sexp_complexp(res))
|
||||
res = sexp_inexact_to_exact(ctx, NULL, 1, res);
|
||||
else
|
||||
#endif
|
||||
if (sexp_flonump(res))
|
||||
#if SEXP_USE_RATIOS
|
||||
|
|
Loading…
Add table
Reference in a new issue