Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The differences between integer & long hexadecimal literals in Oberon dialects #56

Oleg-N-Cher opened this issue Feb 10, 2019 · 0 comments


None yet
1 participant
Copy link

commented Feb 10, 2019

Historically, the LONGINT type in Oberon/Oberon-2 has size 32 bits. And increasing the bit depth of LONGINT type will break compatibility with existing source code. To avoid this problem, some Oberon-implementations use a non-standard type HUGEINT, although it is not present in the description of the Oberon/Oberon-2 language. Therefore, we can consider the type HUGEINT only as a language extension. Accordingly, we should consider the declaration of constants of this type as a language extension too.

With this in mind, and with the need to maintain existing code, we have introduced a new (non-standard) suffix 'L' to declare long hexadecimal literals of (non-standard) type HUGEINT.

As you know, in Oberon/Oberon-2 the real numbers of single precision are written with the suffix "E" (2.44E15), and of double precision -- with 'D' (2.44D15). In Component Pascal, there is no longer the suffix 'D', since there are no single-precision numbers -- all calculations are performed in double. But still, by analogy with this solution in Oberon/Oberon-2, to use the suffix 'L' for long hexadecimal literals seems to be a reasonable solution, only expanding the range of numbers, but not breaking the old code with 32-bit literals.

Ofront+ implements the following ways to define the hexadecimal literals:

-1, -2 (Oberon, Oberon-2): 'H' for 32-bit literals, 'L' for 64-bit literals. Compatible with old code. New code uses 'L' and HUGEINT type as the Oberon/Oberon-2 extensions.

-C (Component Pascal): 'H' for 32-bit literals, 'L' for 64-bit literals. Compatible with Component Pascal.

-7 (Oberon-07): 'H' for INTEGER literals. If a literal > MAX(INTEGER), you receive a compiler warning. The ability to define longer numbers than allowed needed to interact with code in other dialects and to be able to specify literals of the type SYSTEM.INT64).

-3 (Oberon-3, the experimental dialect): 'H' for literals of any integer type. For force converting a LONGINT constant to INTEGER it is offered to use SYSTEM.VAL. This is a normal solution for system conversion of a set of bits into a set of bits with losses.

Note that Oberon/Oberon-2 and Component Pascal have the ability to specify a number sign in the literal implicitly, whereas Oberon-3 and Oberon-07 don't allow it. We decided that it would be wrong to allow implicit sign assignment and any manipulations with a number at the bit level. "Integers are not bits" (Niklaus Wirth)

Oleg-N-Cher added a commit that referenced this issue Feb 10, 2019

Oleg-N-Cher added a commit that referenced this issue Feb 11, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.