From 2014fe43e498d48828c2aa47415d258c181fc347 Mon Sep 17 00:00:00 2001 From: "Jan (janneke) Nieuwenhuizen" Date: Tue, 29 Dec 2020 22:07:30 +0100 Subject: [PATCH] DRAFT core: Avoid Floating point exception. This fixes kaem --verbose --strict bin/mes-m2 -c '(display (number->string -2147483648))' * src/math.c (divide, modulo): Use size_t instead of long for division. --- src/math.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/math.c b/src/math.c index 0b4ae28b..f5d80a81 100644 --- a/src/math.c +++ b/src/math.c @@ -144,9 +144,9 @@ plus (struct scm *x) /*:((name . "+") (arity . n)) */ struct scm * divide (struct scm *x) /*:((name . "/") (arity . n)) */ { - long n = 1; + size_t n = 1; struct scm *i; - long v; + size_t v; if (x != cell_nil) { i = car (x); @@ -175,8 +175,8 @@ modulo (struct scm *a, struct scm *b) { assert_number ("modulo", a); assert_number ("modulo", b); - long x = a->value; - long y = b->value; + size_t x = a->value; + size_t y = b->value; if (y == 0) error (cstring_to_symbol ("divide-by-zero"), a); while (x < 0)