• vishap Oberon and MIN(LONGINT)

    From doug719125@gmail.com@21:1/5 to All on Tue Nov 28 15:08:28 2017
    Using the latest vishap from github (v2.1.0 [2017/11/21] on Ubuntu 16.04.2 x64 Using compile option -OC

    IMPORT Out;

    Out.Int(MIN(LONGINT),0); # produces -9223372036854775808

    Out.Int(-9223372036854775808, 0) # produces Out.Int(-9223372036854775808, 0);
    ^
    pos 138 err 203 number too large

    Out.Int( (MIN(LONGINT)) DIV 10, 0); # produces 922337203685477579

    Out.LongReal( MIN(LONGINT) / 10.0, 20); # produces -9.22337203685478D+017

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David Brown@21:1/5 to All on Wed Nov 29 02:05:30 2017
    This is actually an expected result of the design of two's complement numbers and the way the parser is specified.

    The minus sign is not parsed as part of the number, but as a separate operator. This is required to correctly parse Oberon operator precedence rules.

    Thus the number is parsed as a positive integer.

    The largest possible positive twos complement integer for a given integer size is one less than the absolute value of the largest possible negative integer.

    Thus 9223372036854775807 is parseable, but 9223372036854775808 is not.

    The C compiler does this the same (not that that's saying it's good ...).

    The workaround is to code -9223372036854775807-1, or just MIN(LONGINT).

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)