Unnamed Constants
An unnamed numeric constant has the type UNIVERSAL, which is a 32-bit signed value. When a value of type UNIVERSAL is used in an operation, it is converted to the type of the other operand.
An exception to the above is floating point constants have type FLOAT.
Numeric constants have the following formats:
12 -- decimal
0x12 -- hexadecimal
0b01 -- binary
0q01 -- octal
"a" -- ASCII
1.23 or 1.23e2 or 1.23e-2 -- FLOAT
An ASCII constant evaluates to the first character except when used to initialize a constant or variable array in which case each character is used as one entry.
Example:
CONST ZERO = 0 CONST ZERO_CHAR = "0" CONST ABC_ARRAY[] = "ABC"
The full format of a floating point constant is:
[+|-]###.[###[e[+|-]###]
Example:
VAR BYTE ch = "123" ; ch is set to '1' VAR BYTE str[] = "123" ; str[0] is set to '1' ; str[1] is set to '2' ; str[2] is set to '3'
Sequence | Value |
"\ooo" | octal constant |
"\a" | bell |
"\b" | backspace |
"\f" | form feed |
"\n" | line feed |
"\qooo" | octal constant |
"\r" | carriage return |
"\t" | horizontal tab |
"\v" | vertical tab |
"\xdd" | hexadecimal constant |
"\zbbb" | binary constant |
"\\" | A single '\' |
Constants other than ASCII constants may also contain any number of underscores ("_") which are ignored, but are useful for grouping. For example: 0b0000_1111
Parent topic: Constants