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.
This commit is contained in:
Jan (janneke) Nieuwenhuizen 2020-12-29 22:07:30 +01:00
parent 29b574271e
commit 2014fe43e4
No known key found for this signature in database
GPG Key ID: F3C1A0D9C1D65273
1 changed files with 4 additions and 4 deletions

View File

@ -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)