A constant is a numeric or character value that does not change during program execution. BASIC accepts floating-point, integer, packed decimal, and character string constants. You can create a named constant of any data type with the DECLARE statement. You can also use explicit literal notation to specify the value and data type of a numeric literal.
1 – Literal notation
The format for explicit literal notation is: [radix] num-str-lit [data-type] Radix specifies an optional base and can be: o D Decimal (base 10) - the default o B Binary (base 2) o O Octal (base 8) o X Hexadecimal (base 16) o A ASCII The numeric string can consist of digits and an optional decimal point. You can also use E notation for floating-point constants. A leading minus sign cannot appear inside the quotation marks. Data type is a single letter abbreviation a data type keyword: o B BYTE o W WORD o L LONG o Q QUAD o F SINGLE o D DOUBLE o G GFLOAT o S SFLOAT o T TFLOAT o X XFLOAT o P DECIMAL Data type can also be C, which specifies a single-character string in terms of its 8-bit ASCII value. For the C data type, the value of the numeric string must be between 0 and 255, inclusive. For example: B"11111111"B = BYTE binary constant (-1) X"FF"B = BYTE hexadecimal constant (-1) O"377"B = BYTE octal constant (-1) "7"C = CHARACTER constant (ASCII decimal value 7)
2 – Floating-point
A floating-point constant is a literal or named constant with one or more decimal digits, either positive or negative, an optional decimal point, and an exponent of 10 (E notation). If the default data type is INTEGER, a decimal point or an E is required or BASIC treats the literal as an integer. If the default data type is DECIMAL, an E is required or BASIC treats the literal as a DECIMAL.
3 – Integer
An integer constant is a literal or named constant with one or more digits, either positive or negative, with no fractional digits and an optional trailing percent sign (%). The percent sign is required for integer literals if the default data type is not INTEGER.
4 – Packed Decimal
A packed decimal constant is a number, either positive or negative, that has a specified number of digits (d) and a specified decimal point position (s). You can specify the d and s values when you declare the constant or use explicit literal notation. If you do not specify d and s values, BASIC uses the current defaults for DECIMAL.
5 – String
String constants are either string literals or named constants. A string literal is a series of characters enclosed in double quotation marks ("text") or single quotation marks ('text'). You can embed double quotation marks within single quotation marks ('"text"') and vice versa ("'text'"). Note, however, that the outer quotation marks must be paired.
6 – Named
To name a constant within a program, use the DECLARE CONSTANT statement. To name a constant external to a program, use the EXTERNAL CONSTANT statement.