[Oberon] Size of LONGINT in ETHOberon

Dieter d.gloetzel at web.de
Tue Feb 12 12:30:30 CET 2019


Thanks, I got it. It's difficult to distinguish between "7" and "8"

Regards, Dieter

Am 12.02.2019 um 11:01 schrieb Jörg:
> Dieter
>
> Let's look at the internal representation of a LONGINT (bits 0..31 = 32 bits)
> You basically have two parts:
> - the highest bit (bit 31) is used for the sign
> - the rest (bits 0..30) are the value of the LONGINT.
>
> When using a hexadecimal representation, it's like this
> 00000000H .. 7FFFFFFFH are positive as the bit 31 is 0
> 80000000H .. FFFFFFFFH are negative as the bit 31 is 1
>
> Your program calculates 2^x, x from 0..31.
> 2^31 is in hex 80000000H. So you see, according to the explanation above this is a negative nbr.
> The largest positive number is 2^31-1 = 7FFFFFFFH = 2'147'483'647
>
> br
> Jörg
>
>
> Am 12.02.19, 10:36 schrieb "Oberon im Auftrag von Dieter" <oberon-bounces at lists.inf.ethz.ch im Auftrag von d.gloetzel at web.de>:
>
>      I am using:
>
>      ETH PlugIn Oberon for WindowsTM / Win32 2.5 (18.12.2010)
>            on Windows Vista Version 6.2.9200
>
>      According to NW (Programming in Oberon,Steps beyond Pascal and Modula)
>      the size of LONGINT is +/- 2147483647
>
>      However, when I run
>
>      ==================================================
>
>      MODULE powerof2;
>      IMPORT Out;
>      PROCEDURE power*;
>      VAR i : INTEGER; value : LONGINT;
>      BEGIN
>      i := 0; value := 1;
>      WHILE i < 32 DO
>      Out.Ln(); Out.Int(i,5); Out.Int(value,20);
>      INC(i); value := 2 * value;
>      END;
>      END power;
>      BEGIN
>      END powerof2.power
>
>      ===================================================
>
>      I get
>
>      ===================================================
>
>        0                   1
>           1                   2
>           2                   4
>           3                   8
>           4                  16
>           5                  32
>           6                  64
>           7                 128
>           8                 256
>           9                 512
>          10                1024
>          11                2048
>          12                4096
>          13                8192
>          14               16384
>          15               32768
>          16               65536
>          17              131072
>          18              262144
>          19              524288
>          20             1048576
>          21             2097152
>          22             4194304
>          23             8388608
>          24            16777216
>          25            33554432
>          26            67108864
>          27           134217728
>          28           268435456
>          29           536870912
>          30          1073741824
>          31 -2147483648
>
>      =============================
>
>      Has anybody got an explanation?
>
>      Thanks and bye Dieter
>
>      --
>      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


--
____________________________________
Dr. Dieter Glötzel
Im Rosengarten 27
64367 Mühltal
Tel.: 06151 / 360 82 72



More information about the Oberon mailing list