mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 05:39:18 +02:00
fix exact neg check for ratio in rounding (issue #539)
This commit is contained in:
parent
624b54c05c
commit
26ceb64434
2 changed files with 5 additions and 1 deletions
2
bignum.c
2
bignum.c
|
@ -862,7 +862,7 @@ sexp sexp_ratio_round (sexp ctx, sexp a) {
|
|||
r = sexp_mul(ctx, r, SEXP_TWO);
|
||||
if (sexp_exact_negativep(r)) {sexp_negate(r);}
|
||||
if (sexp_unbox_fixnum(sexp_compare(ctx, r, sexp_ratio_denominator(a))) > 0)
|
||||
q = sexp_add(ctx, q, (sexp_exact_positivep(q) ? SEXP_ONE : SEXP_NEG_ONE));
|
||||
q = sexp_add(ctx, q, (sexp_exact_negativep(sexp_ratio_numerator(a)) ? SEXP_NEG_ONE : SEXP_ONE));
|
||||
}
|
||||
sexp_gc_release2(ctx);
|
||||
return q;
|
||||
|
|
|
@ -932,6 +932,10 @@
|
|||
|
||||
(test 4 (round 7/2))
|
||||
(test 7 (round 7))
|
||||
(test 1 (round 7/10))
|
||||
(test -4 (round -7/2))
|
||||
(test -7 (round -7))
|
||||
(test -1 (round -7/10))
|
||||
|
||||
(test 1/3 (rationalize (exact .3) 1/10))
|
||||
(test #i1/3 (rationalize .3 1/10))
|
||||
|
|
Loading…
Add table
Reference in a new issue