diff --git a/runtime.c b/runtime.c index dc244ac4..c384ccae 100644 --- a/runtime.c +++ b/runtime.c @@ -3167,14 +3167,14 @@ object bignum_minus_unsigned(void *data, object x, object y) case 0: /* x = y, return 0 */ return C_fix(0); case -1: /* abs(x) < abs(y), return -(abs(y) - abs(x)) */ - size = C_fix(C_bignum_size(y)); /* Maximum size of result is length of y. */ + size = C_bignum_size(y); /* Maximum size of result is length of y. */ size = y; y = x; x = size; break; case 1: /* abs(x) > abs(y), return abs(x) - abs(y) */ default: - size = C_fix(C_bignum_size(x)); /* Maximum size of result is length of x. */ + size = C_bignum_size(x); /* Maximum size of result is length of x. */ break; } diff --git a/test-bn.scm b/test-bn.scm index 70917a9e..0b11ddcf 100644 --- a/test-bn.scm +++ b/test-bn.scm @@ -29,6 +29,18 @@ if(is_value_type(result)) { printf(\"fixnum result\\n\"); } else if (type_of(result) == bignum2_tag) { printf(\"bignum result\\n\"); +} + return_closcall1(data, k, result); + ") + (define-c test-minus + "(void *data, int argc, closure _, object k, object fx1, object fx2)" + " object bn1 = Cyc_int2bignum2(data, obj_obj2int(fx1)); + object bn2 = Cyc_int2bignum2(data, obj_obj2int(fx2)); + object result = bignum_minus_unsigned(data, bn1, bn2); +if(is_value_type(result)) { + printf(\"fixnum result\\n\"); +} else if (type_of(result) == bignum2_tag) { + printf(\"bignum result\\n\"); } return_closcall1(data, k, result); ") @@ -69,6 +81,21 @@ if(is_value_type(result)) { (write (test-str2bn "123454354534523454243999" 16)) (newline) +(write "subtraction") +(newline) +(map + (lambda (row) + (write row) + (newline)) + (list + (test-minus 1 1) + (test-minus 1 2) + (test-minus -1 2) + (test-minus (- #x0FFFffff) (- #x0FFFffff)) + (test-minus (- #x2FFFffff) (- #x2FFFffff)) +)) +(newline) + (write "multiplication") (newline) (map