Quick start manual
Data types, variables, and constants
5-43
Declared constants
Declared constants are either true constants or typed constants. These two kinds of
constant are superficially similar, but they are governed by different rules and used
for different purposes.
True constants
A true constant is a declared identifier whose value cannot change. For example,
const MaxValue = 237;
declares a constant called MaxValue that returns the integer 237. The syntax for
declaring a true constant is
const identifier = constantExpression
where identifier is any valid identifier and constantExpression is an expression that the
compiler can evaluate without executing your program. (See “Constant expressions”
on page 5-44 for more information.)
If constantExpression returns an ordinal value, you can specify the type of the declared
constant using a value typecast. For example
const MyNumber = Int64(17);
declares a constant called MyNumber, of type Int64, that returns the integer 17.
Otherwise, the type of the declared constant is the type of the constantExpression.
•If constantExpression is a character string, the declared constant is compatible with
any string type. If the character string is of length 1, it is also compatible with any
character type.
•If constantExpression is a real, its type is Extended. If it is an integer, its type is given
by the table below.
Table 5.8
Range of constant
(hexadecimal)
Range of constant
(decimal)
Type
–$8000000000000000..–$80000001 –2
63
..–2147483649 Int64
–$80000000..–$8001 –2147483648..–32769 Integer
–$8000..–$81 –32768..–129 Smallint
–$80..–1 –128..–1 Shortint
0..$7F 0..127 0..127
$80..$FF 128..255 Byte
$0100..$7FFF 256..32767 0..32767
$8000..$FFFF 32768..65535 Word
$10000..$7FFFFFFF 65536..2147483647 0..2147483647
$80000000..$FFFFFFFF 2147483648..4294967295 Cardinal
$100000000..$7FFFFFFFFFFFFFFF 4294967296..2
63
–1 Int64