80Bus News 
May–June 1983, Volume 2, Issue 3 



Page 20 of 59 




MBASIC permits several ways of processing or printing numbers. 8K ROM BASIC recognises integers and real numbers (integers are numbers without a decimal part – e.g. 10, 3, 1001 or –54); real numbers are those with numbers following the decimal point and are of single precision accuracy (the first seven digits of the number are regarded as significant and the seventh is rounded up). Scientific notation is also allowed – for example, 1,000,000 is 1E6). In addition to these, MBASIC permits the use of double precision (14 significant figures) arithmetic. Numerical constants with more than 7 digits, or a D in place of the E in the exponent are double precision, as are constants followed by a £ sign, as in 1.2534789£. If a constant is followed by an exclamation mark, it is considered as a single precision constant, even if it has more than 7 digits; for example 4.5555671! is interpreted as 4.55556.
MBASIC also allows hexadecimal and octal constants and these must be prefixed by &H or &O respectively; the constant must not contain digits other than 0 – 7 for octal constants, and 0 – 9, with the letters A – F for hexadecimal.
Variables may be declared with single or double precision, or as integers or strings. They may be explicitly declared by ‘type’ as follows:
Type __________________________________________________________ Symbol
String 0 to 255 characters..................................... $
Integer from –32768 to 32767 ..................................... %
Single precision (up to 7 digits, exponent between –38 and +38)...... !
Double precision (up to 16 digits, exponent between –38 and +38)..... £
Types may be changed by explicit definition, another version of DEF; if no type is specified, MBASIC assumes that all variables are single precision. The format of the DEF statement is as follows:
DEFINT a .......defines a as an integer variable
DEFSTR a .......defines a as a string variable
DEFSNG a .......defines a as a single precision real variable
DEFDBL a .......defines a as a double precision real variable
One or more letters may be defined in this way – thus DEFINT I – N defines variable names beginning with the letters I to N as integers and DEFDBL D indicates that variables beginning with the letter D are of double precision type.
Variables in MBASIC can be of any length (within reason) but only the first two alphanumeric characters are used and the first character must be a letter. [Ed. – Different again. Variables may be up to 42 letters or numbers, the first must be a letter and the first letters must not form a reserved word.]
Most users of ROM BASIC will know that a range of mathematical, algebraic and string functions are available. MBASIC has more!
CINT (X) converts X to integer
CSNG (X) converts X to single precision
CDBL (X) converts X to double precision
(the range of the argument for CINT(X) must be between –32768 and 32767,
otherwise an arithmetic overflow occurs)
ERR and ERL respectively give the error code and line number of the last error which has occurred.
This is an OCR’d version of the scanned page and likely contains recognition errors.



Page 20 of 59 



