[Oberon] Assumed issue in the Lola-2 compiler

Skulski, Wojciech skulski at pas.rochester.edu
Mon Apr 15 17:20:10 CEST 2019


Joerg:

  this discussion should become an Appendix to the Language Report. We will then know what we are doing when we write a program using these operators.

Wojtek
________________________________________
From: Oberon [oberon-bounces at lists.inf.ethz.ch] on behalf of Joerg [joerg.straube at iaeth.ch]
Sent: Monday, April 15, 2019 10:53 AM
To: rochus.keller at bluewin.ch; 'ETH Oberon and related systems'
Subject: Re: [Oberon] Assumed issue in the Lola-2 compiler

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

[cid:image003.png at 01D4F3AB.C0FB2A30]



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.

--

Oberon at lists.inf.ethz.ch<mailto:Oberon at lists.inf.ethz.ch> mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon<https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.inf.ethz.ch_mailman_listinfo_oberon&d=DwMFAw&c=kbmfwr1Yojg42sGEpaQh5ofMHBeTl9EI2eaqQZhHbOU&r=uUiA_zLpwaGJIlq-_BM9w1wVOuyqPwHi3XzJRa-ybV0&m=ER49YUosIU_AK9lBnIe3-FHGrEt9WcbbQZvIhCnQEA0&s=cLRrZcojDDGrEAOCDYipJ4TTgJSnYgZcFwd93HnGpYc&e=>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.png
Type: image/png
Size: 11708 bytes
Desc: image003.png
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20190415/c8570689/attachment.png>


More information about the Oberon mailing list