Modula-2 Basic Data Types

This section documents the memory formats used to represent the data values in the Modula-2 language.  For each type, the number of bytes used and the interpretation of the data is given.

Type Storage size Range
INTEGER 16-bit compiler:
  2 bytes
32-bit compiler:
  4 bytes
-32768 to 32767

-2,147,483,648 to 2,147,483,647
CARDINAL 16-bit compiler:
  2 bytes
32-bit compiler:
  4 bytes
0 to 65535

0 to 4,294,967,295
REAL 4 bytes Real numbers with an
approximate range of 8.43E-37 to 3.37E+38 and an accuracy of about 6 decimal digits
LONGREAL 8 bytes Real numbers with an
approximate range of 4.19E-307 to 1.67E+308 and an accuracy of about 15 decimal digits
COMPLEX 8 bytes Complex numbers where the real and imaginary Components are of type REAL
LONGCOMPLEX 16 bytes Complex numbers where the real and imaginary Components are of type LONGREAL
BOOLEAN 1 byte An enumeration type with the values FALSE and TRUE
CHAR ANSI (8-bit):
  1 byte
UNICODE (16-bit):
  2 bytes
A character in the ANSI (8-bit) or UNICODE (16-bit) character set. Character type selectable via a compiler option.
BITSET 2 bytes A PACKEDSET type with an ordinal range of CARDINAL[0..15]
SHORTINT * 1 byte Integer values in the range of -128 to 127
SHORTCARD * 1 byte Integer values in the range of 0 to 255
INTEGER8 * 1 byte Integer values in the range of -128 to 127
CARDINAL8 * 1 byte Integer values in the range of 0 to 255
INTEGER16 * 2 bytes Integer values in the range of -32768 to 32767
CARDINAL16 * 2 bytes Integer values in the range of 0 to 65535
INTEGER32 * 4 bytes Integer values in the range of -2,147,483,648 to 2,147,483,647
CARDINAL32 * 4 bytes Integer values in the range of 0 to 4,294,967,295
INTEGER64 * 8 bytes 32-bit mode only.
Integer values in the range of -2**63 to (2**63)-1
CARDINAL64 * 8 bytes 32-bit mode only.
Integer values in the range of 0 to (2**64)-1

Note: The compiler performs all compile time arithmetic with the INTEGER64 type, therefore constants larger than MAX(INTEGER64) are not supported. The MAX function is supported.
LONGINT * 16-bit compiler:
  4 bytes

32-bit compiler:
  8 bytes
Integer values in the range of
-2,147,483,648 to 2,147,483,647

-2**63 to (2**63)-1
LONGCARD * 16-bit compiler:
  4 bytes

32-bit compiler:
  8 bytes
Integer values in the range of
0 to 4,294,967,295

0 to (2**64)-1
Note: See CARDINAL64.
ACHAR * 1 byte A character in the ANSI (8-bit) character set
UCHAR * 2 bytes A character in the UNICODE (16-bit) character set
BYTEBOOL *
BOOL8 *
1 byte An enumeration type with the values FALSE and TRUE
WORDBOOL * BOOL16 * 2 bytes An enumeration type with the values FALSE and TRUE
DWORDBOOL * BOOL32 * 4 bytes An enumeration type with the values FALSE and TRUE. Useful when interfacing with C code.
BITSET16 * 2 bytes A PACKEDSET type with an ordinal range of CARDINAL[0..15]
BITSET32 * 4 bytes A PACKEDSET type with an ordinal range of CARDINAL[0..31]

* An extended type specific to Stony Brook Modula-2.