[Oberon] Assumed issue in the Lola-2 compiler

Aubrey McIntosh aubrey.mcintosh at utexas.edu
Tue Apr 16 12:57:27 CEST 2019


Somewhere in my past I took a course that included the theory of numbers,
and it included the definition of division.  Since then I have always been
interested and attentive to that definition.

There is a very close connection between the MOD operator in mathematics
and the so called "clock numbers."  Those are the familiar everyday numbers
MOD 12.

The Oberon definition follows the mathematical definition.

If we call noon today "0" and we are plotting a graph, we want 1 hour
before noon to be graphed at 11, pretty much as we do in the graph of MOD 8
in this conversation.  So making strip charts and such with time data
results in "as expected" results.

Many calculators and also runtime environments for other languages do this
incorrectly.  They simply carry the negative sign into the results for both
mod and div.  This is not correct behavior from a mathematician's point of
view.



On Mon, Apr 15, 2019 at 9:54 AM Joerg <joerg.straube at iaeth.ch> wrote:

> 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.
>
> --
>
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
> https://lists.inf.ethz.ch/mailman/listinfo/oberon
> --
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
> https://lists.inf.ethz.ch/mailman/listinfo/oberon
>


-- 
Aubrey McIntosh, PhD
Teaching Specialist, Chemistry Department
The University of Texas at Austin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20190416/31548d3d/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/20190416/31548d3d/attachment.png>


More information about the Oberon mailing list