[Oberon] Negative integer literals in Oberon

Michael Schierl schierlm at gmx.de
Tue Apr 28 14:50:38 CEST 2020


Am 27.04.2020 um 22:10 schrieb Jörg:
>
>>    ASSERT(0FFFFFFFFH = -1) (*require two's complement *)
>
> On strict compilers this statement does not even compile as 0FFFFFFFFH is not a valid INTEGER.
>
> Could somebody give me a good example, where INTEGERs need a hex notation?

Depends how exactly you define "INTEGERs" for. If I understand you
correctly, in your opinion INTEGERs are the data type that is used for
arithmetic operations without caring of the memory layout.

In that case, it is quite common to give cryptographic parameters (e.g.
RSA modulus or ECC curve parameters) in hexadecimal. Most of them
(except the infamous 0x010001) will not fit into a 32-bit INTEGER, but
still they are defined in Hex and you do arithmetic (multiplication,
addition, exponentiation, modulus, modInverse) with them and hope that
no overflow happens.

AES keys or checksums are also often given in hex, but in this case the
size and representation of the values is also fixed, so probably a
purist would use a different data type than (BIG)INTEGER for it.


Regards,


Michael


More information about the Oberon mailing list