[Oberon] Assumed issue in the Lola-2 compiler
Hellwig Geisse
hellwig.geisse at mni.thm.de
Tue Apr 16 09:42:39 CEST 2019
Hi all,
just two remarks:
1.
On Mo, 2019-04-15 at 16:53 +0200, joerg.straube at iaeth.ch wrote:
> In my point of view the Oberon spec is rather clear:
> q = x DIV y, r = x MOD y, x = q*y + r, 0 <= r < y
This implies 0 < y and leaves the case y <= 0 unspecified
(y = 0 can of course be excluded).
2.
On Mo, 2019-04-15 at 14:35 +0200, rochus.keller at bluewin.ch wrote:
> Ok, I think I found a decent solution.
> [..]
> But I can avoid this indetermination by using the following
> two functions and re-using features of the C language.
The C language spec is rather reluctant to exactly
define the result of the % operator (at least the
C89 version; I didn't look into the newer standards).
It says (K&R, 2nd edition, A7.6 Multiplicative Operators):
".. it is always true that (a/b)*b + a%b is equal to a.
If both operands are non-negative, then the remainder is
non-negative and smaller than the divisor; if not, it is
guaranteed only that the absolute value of the remainder
is smaller than the absolute value of the divisor."
The implication of this is that you cannot use %
consistently across implementations (and not even
within an implementation) if any of its arguments
could be negative.
Regards,
Hellwig
More information about the Oberon
mailing list