48 of 208
ZBasic Language Reference 40 ZX Microcontroller Family 2.6.2 Numeric Literals - Integral Values A decimal integral numeric literal consists of decimal digits optionally with a leading plus or minus sign to indicate a positive or negative literal value. Integral literals may be specified in hexadecimal (base 16) by beginning the literal with an ampersand and the letter H (upper or lower case) followed by one or more hexadecimal digits (0-9, A-F, a-f). In BasicX compatibility mode, a trailing ampersand is either allowed, required or disallowed depending on the specific value and whether or not Strict mode is enabled. In native ZBasic mode the trailing ampersand is always allowed, is never required and has no effect whatsoever on the resulting value. Integral literals may also be specified in binary (base 2) by beginning the literal with an ampersand and the letter B (upper or lower case) followed by one or more binary digits (0-1). To improve readability, you may also include one or more underscores within the digit string provided that each underscore occurs between two digits. For compatibility with other Basic dialects, an upper or lower case X may be used in place of the radix indicator B. Binary literals are not supported in BasicX compatibility mode. Examples of decimal, hexadecimal and binary integral literals: 124 +16 -357 &HabCd &H8000& &B0010_0011 2.6.3 Numeric Literals - Real Values A real numeric literal consists of one or more decimal digits, optionally with a leading plus or minus sign, followed by either a decimal point and one or more decimal digits or the letter E followed by one or more decimal digits also optionally prefixed by a plus or minus sign. If the fractional part is present, it may also be followed by an exponent specification. For compatibility with other Basic dialects, a literal that would otherwise be an integral literal will be interpreted as a real literal if it is immediately followed by an exclamation mark. Real literals have the type Single. Examples of real literals: 3.14159 +6.02e23 3e10 -300! BasicX Compatibility Note In BasicX compatibility mode, real literals must either contain a decimal point or have a type designation suffix ! or # to force them to be recognized as type Single. A literal like 12e2 represents the integer value 1200. 2.6.4 String Literals A string literal consists of zero or more characters enclosed in quotation marks. Note that a string may not be continued on the next line by ending the first line with an underscore. However, you may use the concatenation operator in conjunction with the underscore continuation to span line boundaries. The compiler will combine the operands to the concatenation operator as long as they are both string constants. String literals have the type String.