Quick start manual
5-4
Delphi Language Guide
Simple types
Integer types
An integer type represents a subset of the whole numbers. The generic integer types
are Integer and Cardinal; use these whenever possible, since they result in the best
performance for the underlying CPU and operating system. The table below gives
their ranges and storage formats for the current 32-bit Delphi compiler.
Fundamental integer types include Shortint, Smallint, Longint, Int64, Byte, Word, and
Longword.
In general, arithmetic operations on integers return a value of type Integer—which, in
its current implementation, is equivalent to the 32-bit Longint. Operations return a
value of type Int64 only when performed on one or more Int64 operand. Hence the
following code produces incorrect results.
var
I: Integer;
J: Int64;
ƒ
I := High(Integer);
J := I + 1;
To get an Int64 return value in this situation, cast I as Int64:
ƒ
J := Int64(I) + 1;
For more information, see “Arithmetic operators” on page 4-7.
Note
Some standard routines that take integer arguments truncate Int64 values to 32 bits.
However, the High, Low, Succ, Pred, Inc, Dec, IntToStr, and IntToHex routines fully
support Int64 arguments. Also, the Round, Trunc, StrToInt64, and StrToInt64Def
functions return Int64 values. A few routines cannot take Int64 values at all.
Table 5.1 Generic integer types for 32-bit implementations of Delphi
Type Range Format
Integer –2147483648..2147483647 signed 32-bit
Cardinal 0..4294967295 unsigned 32-bit
Table 5.2 Fundamental integer types
Type Range Format
Shortint –128..127 signed 8-bit
Smallint –32768..32767 signed 16-bit
Longint –2147483648..2147483647 signed 32-bit
Int64 –2
63
..2
63
–1 signed 64-bit
Byte 0..255 unsigned 8-bit
Word 0..65535 unsigned 16-bit
Longword 0..4294967295 unsigned 32-bit