[Oberon] Easter eggs in Oberon

Joerg joerg.straube at iaeth.ch
Mon Apr 13 21:36:39 CEST 2020


August

If you write this:

VAR i: INTEGER;
i := 4000000;
i := i * 4000000;

would you state the result is „undefined“?
I would say: it wraps around (or overflows) and is identical to.

i := 1246822400;

With this in mind, you could apply this to BYTE: if the result is not in the range 0..255 it just wraps around or overflows or underflows, but is not undefined.

br
Jörg

> Am 13.04.2020 um 21:20 schrieb Joerg <joerg.straube at iaeth.ch>:
> 
> August
> 
> Where is defined what the operator / shall do?
> I mean who does forbid me to state / is equal to DIV if both operands are INTEGER.
> 
> br
> Jörg
> 
>>> Am 13.04.2020 um 20:49 schrieb August Karlstrom <fusionfile at gmail.com>:
>>> 
>>> On 2020-04-13 17:36, Joerg wrote:
>>> The word „numeric type“ is not clearly defined in the report.
>>> Eg. is BYTE part of the numeric types?
>> 
>> BYTE is defined as "the integers between 0 and 255" and integers are numeric, so the answer must be yes.
>> 
>>> Or is INTEGER part of the numeric type?
>> 
>> It has to be, otherwise you would not able to calculate anything with integers.
>> 
>>> If it was you sould be able to write i := i / 3;  (as / is defined on numeric types)...
>> 
>> No, because "The operators +, −, *, and / apply to operands of numeric types. Both operands must be of the same type, which is also the type of the result." The result of i / 3 is not an integer unless i is a multiple of three. Therefor it applies to operands of type REAL.
>> 
>>> The Oberon report leaves some room for interpretation... (especially for corner cases)
>>> b := -2;  is equivalent to b := 254;
>> 
>> It may give the same result on one implementation but it is still undefined; again the Oberon report says that BYTE is "the integers between 0 and 255," not "the integers between -128 and 127."
>> 
>> 
>> -- August
>> --
>> 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



More information about the Oberon mailing list