diff --git a/bignum.c b/bignum.c index 37b2de8e..526fa536 100644 --- a/bignum.c +++ b/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; diff --git a/tests/r7rs-tests.scm b/tests/r7rs-tests.scm index 174d9ba8..998abcc4 100644 --- a/tests/r7rs-tests.scm +++ b/tests/r7rs-tests.scm @@ -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))