From 4c7ca3edb293dd0adb3c97f11820439619d37417 Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Thu, 30 Jun 2011 09:17:47 +0900 Subject: [PATCH] fixing bug in mixed fixnum/flonum subtraction --- opt/bignum.c | 2 +- tests/r5rs-tests.scm | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/opt/bignum.c b/opt/bignum.c index 77619d2e..f68f4821 100644 --- a/opt/bignum.c +++ b/opt/bignum.c @@ -554,7 +554,7 @@ sexp sexp_sub (sexp ctx, sexp a, sexp b) { r = sexp_bignum_normalize(r); break; case SEXP_NUM_FLO_FIX: - r = sexp_make_flonum(ctx, sexp_fixnum_to_double(b)+sexp_flonum_value(a)); + r = sexp_make_flonum(ctx, sexp_flonum_value(a) - sexp_fixnum_to_double(b)); break; case SEXP_NUM_FLO_FLO: r = sexp_fp_sub(ctx, a, b); diff --git a/tests/r5rs-tests.scm b/tests/r5rs-tests.scm index 41919386..048c36d7 100644 --- a/tests/r5rs-tests.scm +++ b/tests/r5rs-tests.scm @@ -205,6 +205,8 @@ (test -3 (- 3)) +(test -1.0 (- 3.0 4)) + (test 7 (abs -7)) (test 1 (modulo 13 4))