From 1d4b8bf08a7662c1f92a11a87b79c57050e494f1 Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Wed, 10 Aug 2022 07:16:04 -0700 Subject: Subtract int-min instead of adding int-max + 1. --- lib/scheme/base/80-number.csc | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'lib/scheme/base/80-number.csc') diff --git a/lib/scheme/base/80-number.csc b/lib/scheme/base/80-number.csc index 171bbd0..4b83874 100644 --- a/lib/scheme/base/80-number.csc +++ b/lib/scheme/base/80-number.csc @@ -170,11 +170,7 @@ (define (add2 x y) (define z (call-builtin add x y)) (if (negative? z) - (values 1 (call-builtin add - 1 - (call-builtin add - z - small-int-max))) + (values 1 (call-builtin sub z small-int-min)) (values 0 z))) @@ -289,9 +285,7 @@ (if (int-negative? x) (begin (vector-set! out-digits i - (call-builtin add - 1 - (call-builtin add x small-int-max))) + (call-builtin sub x small-int-min)) (loop (+ 1 i) -1)) (begin (vector-set! out-digits i x) @@ -303,9 +297,7 @@ (if (int-negative? x) (begin (vector-set! out-digits i - (call-builtin add - 1 - (call-builtin add x small-int-max))) + (call-builtin sub x small-int-min)) (loop (+ 1 i) -1)) (begin (vector-set! out-digits i x) -- cgit v1.3.1