[Oberon] Negative integer literals in Oberon

Jörg joerg.straube at iaeth.ch
Sun Apr 26 16:24:34 CEST 2020


Dave

I was only refering to Oberon-07. The semantic in previous Oberons (and Oberon dialects) was different than Oberon-07.

I find the implemented semantic of hex values in the Oberon-07 compiler cleaner.

In Oberon-07, you can write
  b := 0FFFFFFFFFFFFH;
  i := 0FFFFFFFFFFFFH;

the results are: b = 255 and i = -1.

Jörg
> MODULE Test; IMPORT Out;
> 
> PROCEDURE Do*;
> VAR b: BYTE; s: SHORTINT; i: INTEGER; l: LONGINT;
> BEGIN
>   i := 0FFFFFFFFH; Out.String("i := 0FFFFFFFFH: "); Out.Int(i,1); Out.Ln;
>   l := 0FFFFFFFFH; Out.String("l := 0FFFFFFFFH: "); Out.Int(l,1); Out.Ln;
>   l := 0FFFFFFFFL; Out.String("l := 0FFFFFFFFL: "); Out.Int(l,1); Out.Ln;
>   l := 0FFFFFFFFFFFFFFFFL; Out.String("l := 0FFFFFFFFFFFFFFFFL: "); Out.Int(l,1); Out.Ln;
>   (* The following all fail to compile with 'number too large': 
>     b := 0FFH;
>     s := 0FFFFH;
>     i := 0FFFFFFFFL;
>     l := 0FFFFFFFFFFFFFFFFH;
>   *)
> END Do;
> 
> END Test.
> 
> With results:
> 
>   i := 0FFFFFFFFH: -1
>   l := 0FFFFFFFFH: -1
>   l := 0FFFFFFFFL: 4294967295
>   l := 0FFFFFFFFFFFFFFFFL: -1
> 
> So I understand the H/L suffix enables the use of hex bit patterns for 32 and 64 bit integers, but does not address the issue for 8 or 16 bit integers.
> 
> Do you know if there is any way to enable e.g. FF for bytes, or FFFF for shortints? Or whether this was considered?
> 
> Thanks --
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20200426/c14091e0/attachment.html>


More information about the Oberon mailing list