Data types of an entity (for example variables and constants) define the meaning, constraints, possible values, functions and mode of storage associated with it. Integer, float, Boolean and character types are referred to as standard types. Data types can be categorized as scalar, pointer and structure data types.
Pronounced /in-tij-ər/ is a noun, means a whole number; a number that is not a fraction. In Modern Pascal, there are 4 sizes of integer, 8bit, 16bit, 32bit and 64bit used to hold whole number values from the minimum to the maximums below:
Type | Minimum | Maximum | Format |
Byte | 0 | 255 | unsigned 8-bit |
Shortint | -128 | 127 | signed 8-bit |
Word | 0 | 65,535 | unsigned 16-bit |
Smallint | -32,768 | 32,767 | signed 16-bit |
Cardinal | 0 | 4,294,967,295 | unsigned 32-bit |
LongWord | 0 | 4,294,967,295 | unsigned 32-bit |
Integer | -2,147,483,648 | 2,147,483,647 | signed 32-bit |
Longint | -2,147,483,648 | 2,147,483,647 | signed 32-bit |
Int64 | -9,223,372,036,854,775,808 | 9,223,372,036,854,775,807 | signed 64-bit |
LargeInt | -9,223,372,036,854,775,808 | 9,223,372,036,854,775,807 | signed 64-bit |
Short for floating point,denoting a mode of representing numbers as two sequences of bits, one representing the whole number and the other determines the fraction. In Modern Pascal, there are 3 sizes of float, 4byte, 8byte and 10byte used to hold number values from the minimum to the maximums below:
Type | Minimum | Maximum | Significant Digits | Format |
Single | 1.5E-45 | 1.5E-45 | 7 to 8 places | 4-byte |
Double | 5.0E-324 | 1.7E308 | 15 to 16 places | 8-byte |
Extended | 1.9E-4932 | 1.1E4932 | 19 to 20 places | 10-byte |
Currency | -922337203685477.5808 | 922337203685477.5807 | 19 to 20 places | 8-byte |
In Modern Pascal, there are 3 distinct types of character types, single, wide and unicode. There are two distinct versions of these 3 times, single and multiple character collections or strings.
Type | Minimum | Maximum | Format |
AnsiChar | #0 | #255 | 1-byte |
Char | #0 | #255 | 1-byte |
WideChar | #0#0 | #255#255 | 2-byte UTF-16 |
UnicodeChar | #0#0 | <CodePage> | 2-byte Limited |
AnsiString | #0 | #255 | 0-byte to 255-bytes |
String | #0 | #255 | 0-byte to 4 Gig |
WideString | #0#0 | #255#255 | 0-byte to 4 Gig |
UnicodeString | #0#0 | <CodePage> | 0-byte to 4 Gig |
PAnsiChar | #0 | #255 | Unlimited |
PChar | #0#0 | #255#255 | Unlimited |
PWideChar | #0#0 | #255#255 | Unlimited |
In Modern Pascal there are 4 boolean variable types. They are different memory sizes for memory alignment, but contain true and false, or 0 for false and non-zero for true.
Type | Minimum | Maximum | Ord(True) | Format |
Boolean | False | True | Any non-zero | 1-byte |
ByteBool | False | True | Any non-zero | 1-byte |
WordBool | False | True | Any non-zero | 2-Byte |
LongBool | False | True | Any non-zero | 4-byte |
In Modern Pascal enumerated types are a special way of creating your own variable types.
Type | Enumerators |
Direction | (North, East, South, West) |
Days | (monday, tuesday, wednesday, thursday, friday, saturday, sunday) |
In Modern Pascal subrange types are a range values from an ordinal type. To define a subrange type, you must specify its limiting values, minimum to maximum. Subrange types can also be of the above enumeration types.
Type | Range |
Longint | -$80000000..$7FFFFFFF |
Byte | 0..255 |
WeekDays | monday..friday |
WeekEnd | saturday..sunday |
In Modern Pascal a variable of the pointer type references an address in memory, where the data of another variable may be stored. Pointers are a type, which means that they point to a particular kind of data. From a character type, to a structured record type and even an instance of an object structure or class type.
Type | Of | Syntax(es) |
Pointer | any address and size in memory | GetMem(Var,2048), Var:=AllocMem(2048) |
^Type | Type, used for heap allocation of instance of type | New(Var) |
Instance | of a class | Var.Init; |
A structured type is a type that can hold multiple values in one variable. Structured types can be nested to unlimited levels.
Types |
array type |
record type |
class type |
set type |
Static arrays are predefined number of elements of a specified type. Modern Pascal supports multidimensional arrays written in long form.
Static Array | Multidimensional Static Array |
Var A:Array [0..6] of Integer; | Var A:Array [0..6] of Array[0..9] of Integer; |
Var S:Array [1..5] of String; | Var S:Array [1..5] of Array[1..3] of String; |
Const Pass=5; Fail=3; | |
Var Points:Array[Fail..Pass] of Integer; | Var A:Array[0..6] of Array[0..4] of Array[0..9] of Integer; |
Dynamic Arrays are useful when you do not know the upper limit in advance. Using the SetLength() command you can dynamically increase and decrease the size of the zero based array.
Dynamic Array | Multidimensional Dynamic Array |
Var A:Array of Integer; | Var A:Array of Array of Integer; |
Var S:Array of String; | Var S:Array of Array of String; |
SetLength(A,10); | SetLength(A,10); SetLength(A[0],10); |
SetLength(S,10); | SetLength(S,10); SetLength(S[0],10); |
Modern Pascal supports fixed records and records with variant parts. The variant part must be the last in the record. The optional identifier in the case statement serves to access the tag field value, which otherwise would be invisible to the programmer. It can be used to see which variant is active at a certain time. In effect, it introduces a new field in the record.
Modern Pascal supports the set types as defined years ago in Turbo Pascal. Each of the elements of the set's type must be of the target type. Where Target type can be any ordinal type with a range between 0 (zero) and 255. A set can contain at most 255 elements.