aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRose Hogenson <rhogenson@posteo.net>2022-08-10 07:16:04 -0700
committerRose Hogenson <rhogenson@posteo.net>2022-08-10 07:16:04 -0700
commit1d4b8bf08a7662c1f92a11a87b79c57050e494f1 (patch)
treef6c69fac9f79702c624f1b2aeab6b16b0dcd06b3 /lib
parent13e380cadd4ceb2efbc9e7256ca4609f4ed04133 (diff)
downloadchromatopelma-1d4b8bf08a7662c1f92a11a87b79c57050e494f1.tar.zst
Subtract int-min instead of adding int-max + 1.
Diffstat (limited to 'lib')
-rw-r--r--lib/scheme/base/80-number.csc14
1 files changed, 3 insertions, 11 deletions
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)