Integers

Describes integer data types

Integers are whole numbers with no fractional part. In PBL all integer types are signed. Integers are suitable for storing unit quantities and are also used within program code as counters in loops or to handle various system values such as colors, character codes, and so on.

In PBL, integers constants can be specified in one of three bases:
Type Example Digits Allowed
octal 0567 0, 1, 2, 3, 4, 5, 6, 7
decimal 579 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
hexadecimal 0x5AF3 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F

Octal (base 8) numbers are prefixed by a 0 (zero), and are rarely used. Hexadecimal (base 16) numbers are prefixed by '0x' and may be required for some types of values. However, in most situations with PBL, only decimal (base 10) integers will be used. These should not be confused with the Decimal data type, described below.

Integer variables have a fixed range of values that depends on their size in bits, or precision, as follows:
Precision Maximum Value Minimum Value
64 9,223,372,036,854,775,807 -9,223,372,036,854,775,808
32 2,147,483,647 -2,147,483,648
16 32,767 -32,768
8 127 -128
Precision is specified in parenthesis after the data type, as follows:
n As Int(<precision>)
For example, if you wish to declare a 32-bit Int variable, you would use:
n As Int(32)
Note: Only the four precision values shown in the table are defined for integers.