[Oberon] Assumed issue in the Lola-2 compiler
Joerg
joerg.straube at iaeth.ch
Mon Apr 15 16:53:30 CEST 2019
All
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
- MOD is always positive ( 0 <= r < y)
- It follows this pattern
For x = -1 and y = 8 the only integers fulfilling the defining equation set
is q = -1, r = 7.
DIV is rounding down to nearest integer.
br
Jörg
-----Original Message-----
From: Oberon <oberon-bounces at lists.inf.ethz.ch> On Behalf Of
rochus.keller at bluewin.ch
Sent: Monday, April 15, 2019 4:13 PM
To: oberon at lists.inf.ethz.ch
Subject: Re: [Oberon] Assumed issue in the Lola-2 compiler
@ Paul Reed:
>> -1/16 is -0.0625 not 0. (I agree there are indeed multiple integer
>> solutions if you don't also add the range restriction on r.)
>From the language report we can conclude that the operators and result of
DIV and MOD (i.e. x, y, q and r) are (algebraic) integers.
We can also assume that in the equation 'x = q*y + r' the multiplication and
addition are proper mathematical operators.
Since the given equation uses mathematical operators we can expect that
rounding also follows proper mathematical rules. Therefore the rational
number -1/16 is rounded to the algebraic integer 0, which would be the
mathematically proper solution of q = x DIV y = ( x - r ) / y with x = -1
and y = 16.
But as mentioned: I have a viable solution which re-uses features of C to
simulate the Oberon implementation.
Best
R.K.
--
<mailto:Oberon at lists.inf.ethz.ch> Oberon at lists.inf.ethz.ch mailing list for
ETH Oberon and related systems
<https://lists.inf.ethz.ch/mailman/listinfo/oberon>
https://lists.inf.ethz.ch/mailman/listinfo/oberon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20190415/91aa7716/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.png
Type: image/png
Size: 11708 bytes
Desc: not available
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20190415/91aa7716/attachment.png>
More information about the Oberon
mailing list