Name
Integer Type
Syntax
type Integer = -2147483648..2147483647;
Description
The Integer type is the basic integer type. The
size of an integer can vary with different versions of Delphi.
Currently, Integer is a 32-bit type, but future
versions might change the size.
Delphi defines a number of integer types of varying ranges. The predefined integer types are shown in the following table.
|
Type |
Minimum |
Maximum |
|
Byte |
0 |
255 |
|
ShortInt |
-128 |
127 |
|
Word |
0 |
65,535 |
|
SmallInt |
-32,768 |
32,767 |
|
LongWord |
0 |
4,294,967,295 |
|
LongInt |
-2,147,483,648 |
2,147,483,647 |
|
Integer |
natural |
natural |
|
Cardinal |
0 |
natural |
|
Int64 |
-9,223,372,036,854,775,808 |
9,223,372,036,854,775,807 |
Tips and Tricks
Numeric constants are type
Integerif they fall within the range ofInteger; otherwise, they are of typeInt64. Arithmetic expressions with at least one argument of typeInt64yield a result of typeInt64. If both arguments are integer types, the result type isInteger.The size of the
CardinalandIntegertypes can change from one release of Delphi to another. In Delphi 5, both are 32 bits, but a future version of Delphi will undoubtedly change the size to 64 bits.Whenever possible, you should use an explicit subrange. If you know that a value will always be positive, for example, declare the variable accordingly. The additional type safety helps catch mistakes (where you accidentally assign a nonpositive number to the variable), and it helps to document the program by giving the reader additional information ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access