[Oberon] Negative integer literals in Oberon
joerg.straube at iaeth.ch
Mon Apr 27 10:02:53 CEST 2020
How the sign bit for INTEGER values have to be stored is NOT defined in the report. This is part of the presentation layer that is deliberately left to the implementation.
1. Should the following assertion be successful?
ASSERT(ABS(0FFFFFFFFH) = 0FFFFFFFFH);
No, on a 32 bit machine with simple presentation layer implementation
Yes, on a 32 bit machine with clever presentation layer implementation.
Yes, on a 64 bit machine.
2. Should the compiler accept the following statement?
i := i DIV 0FFFFFFFFH;
Yes, why not? Just look at the case where INTEGER is 8 bytes.
But be aware: as I said H has two different flavors: one H usage is used in INTEGER arithmetic (just use decimal notation and hexadecimal notions for the same INTEGER values, there I wonder why you would do that anyway). And the second H usage (and this is in my experience the usage most have in mind when they use H: low-level programming where you need bit patterns and don't care about the internal presentation layer of INTEGERs that is - as we know - not defined in the Oberon report.
More information about the Oberon