[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-mes] ARM mes on wip-arm - Test failure: Division with negative oper

From: Danny Milosavljevic
Subject: [bug-mes] ARM mes on wip-arm - Test failure: Division with negative operands
Date: Mon, 11 Mar 2019 21:49:55 +0100


there's one test failure (on "make check") left:

FAIL: tests/srfi-13.test


test: number->string INT-MIN: fail
expected: "-2147483648"
actual: "-./,),(-*,("
: fail

That's because mes/module/mes/scm.mes defines:

(define (remainder x y)
  (- x (* (quotient x y) y)))

But rounding of integer division in C is implementation-defined, see also 

Currently, ldiv rounds towards zero (as does ISO C99).

That means for example (-1)/2 == 0 (no, seriously).

So (remainder -1 2) => (- -1 (* 0 2)) = -1.  But other parts of the code assume 
(and mainstream mathematics define) remainder >= 0.

Rounding quotient towards zero is kinda silly (better would be to always round 
in the same direction :P) but the hardware industry seems to have standardized 
on it.

In any case, we cannot have both at the same time, so what shall we do?

Attachment: pgpGmWfcLAYZ6.pgp
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]