Skip to content

Integer (Integer, Cardinal, Int64, LongInt) ​

The default value for this data type is zero (0) - it cannot ever be “null”.

Integer is used to represent whole numbers - a number without any decimal places. An Integer can store a number between the range of -2147483648 and 2147483647. If a field within a DB Definition or File Definition is specified as Integer, you do not need to provide a display format.

Cardinal is an unsigned integer because it does not carry a positive (+) or negative (-) assignment. It is also a whole number with no decimal places (integer), but a Cardinal data type allows you to store a much larger number because it does not need to store a sign to indicate a positive or negative number - which is why it is called an unsigned integer. But because it is unsigned, it is not possible to store a negative number in a Cardinal. A Cardinal can store a number between 0 and 4294967295.

Int64 uses more memory to allow you to store an even larger number. Int64 can store both positive and negative numbers, and can store a number between -2^63 and 2^63-1.

LongInt is a 4-byte signed 32-bit integer with the range set to the same size as an integer, at -2147483648 to 2147483647.

But remember, if you try to store a number in a data type that is unable to fit that number, you will receive an Overflow error.

Declaration: var myvariable : integer;

var mylargepositivevariable : cardinal;

var mylargevariable : Int64;

var myextravariable : longint;

Following are examples of the use of these. Please also refer to Word (Double Byte).

pascal
procedure ScriptEvent (var Value : variant);
var
  myvariable, mynegative : integer;
  mylargepositivevariable : cardinal;
  mylargevariable : Int64;
  myextravariable : longint;
begin
  myvariable := 123;
  loginfo('The value of myvariable is '+IntToStr(myvariable));
  mynegative := -4567;
  loginfo('The value of mynegative is '+IntToStr(mynegative));
  mylargepositivevariable := 4294967294;
  loginfo('The value of mylargepositivevariable is '+IntToStr(mylargepositivevariable));
  mylargevariable := 7643219876543529;
  loginfo('The value of mylargevariable is '+IntToStr(mylargevariable));
  myextravariable := -2139876541;
  loginfo('The value of myextravariable is '+IntToStr(myextravariable));
end;

This example appears in the Log as follows -

image-20240131-005149.png