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:
parent
29b574271e
commit
2014fe43e4
|
@ -144,9 +144,9 @@ plus (struct scm *x) /*:((name . "+") (arity . n)) */
|
||||||
struct scm *
|
struct scm *
|
||||||
divide (struct scm *x) /*:((name . "/") (arity . n)) */
|
divide (struct scm *x) /*:((name . "/") (arity . n)) */
|
||||||
{
|
{
|
||||||
long n = 1;
|
size_t n = 1;
|
||||||
struct scm *i;
|
struct scm *i;
|
||||||
long v;
|
size_t v;
|
||||||
if (x != cell_nil)
|
if (x != cell_nil)
|
||||||
{
|
{
|
||||||
i = car (x);
|
i = car (x);
|
||||||
|
@ -175,8 +175,8 @@ modulo (struct scm *a, struct scm *b)
|
||||||
{
|
{
|
||||||
assert_number ("modulo", a);
|
assert_number ("modulo", a);
|
||||||
assert_number ("modulo", b);
|
assert_number ("modulo", b);
|
||||||
long x = a->value;
|
size_t x = a->value;
|
||||||
long y = b->value;
|
size_t y = b->value;
|
||||||
if (y == 0)
|
if (y == 0)
|
||||||
error (cstring_to_symbol ("divide-by-zero"), a);
|
error (cstring_to_symbol ("divide-by-zero"), a);
|
||||||
while (x < 0)
|
while (x < 0)
|
||||||
|
|
Loading…
Reference in New Issue