Node:Integer Types with Specified Size, Next:Integer Types and Compatibility, Previous:Main Branch Integer Types, Up:Integer Types
In some situations you will need an integer type of a well-defined
size. For this purpose, GNU Pascal provides type attributes
(see attribute). The type
Integer attribute (Size = 42)
is guaranteed to have a precision of 42 bits. In a realistic context, you will most often give a power of two as the number of bits, and the machine you will need it on will support variables of that size. If this is the case, the specified precision will simultaneously be the amount of storage needed for variables of this type.
In short: If you want to be sure that you have a signed integer with
32 bits width, write Integer attribute (Size = 32)
, not just
Integer
which might be bigger. The same works with unsigned
integer types such as Cardinal
and Word
and with
Boolean types.
This way, you can't get a higher precision than that of
LongestInt
or LongestCard
(see
Main Branch Integer Types). If you need higher precision, you
can look at the GMP
unit (see GMP) which provides integer
types with arbitrary precision, but their usage is different from
normal integer types.