<< Click to Display Table of Contents >> Home mIoTa BASIC > mIoTa BASIC Language Reference > Lexical Elements > Tokens > Literals |
Literals are tokens representing fixed numeric or character values.
Integral values can be represented in decimal, hexadecimal or binary notation.
In decimal notation, numerals are represented as a sequence of digits (without commas, spaces or dots), with optional prefix + or - operator to indicate the sign. Values default to positive (2345 is equivalent to +2345).
The dollar-sign prefix ($) indicates a hexadecimal numeral (for example, $9F).
The percent-sign prefix (%) indicates a binary numeral (for example, %01011111).
Here are some examples:
11 // decimal literal $11 // hex literal, equals decimal 17 %11 // binary literal, equals decimal 3 |
The allowed range of values is imposed by the largest data type in mIoTa BASIC – longint. Compiler will report an error if the literal exceeds 2147483647 ($7FFFFFFF).
A character literal is one character from the extended ASCII character set, enclosed with apostrophes (').
Character literal can be assigned to variables of the STRING type.
Note : Double quotes (" ") have no special meaning in mIoTa BASIC.
String literal is a sequence of characters from the extended ASCII character set, written in one line and enclosed with apostrophes. Whitespace is preserved in string literals and they are treated as single tokens.
Here are some examples of string literals:
'Hello' // string, 5 characters long 'Hello World' // string, 11 characters long ' ' // two spaces, 2 characters long 'C' // letter, 1 characters long '' // null string, 0 characters long |
The apostrophe (') itself cannot be a part of the string literal, but you can use the built-in function CHAR to print an apostrophe Char(39).
Related topics: Data Types