Indications are, the data types in SmileBasic V1 are the same as in SmileBasic V2.


Primitive data typesEdit

SmileBasic V2 has two primitive data types, numeric and string.


A numeric value in SmileBasic V2 is any value from -524287.999755859375 to 524287.999755859375 in steps of 0.000244140625; more concisely, any value of the form x/4096 where x is an integer between -2147483647 and 2147483647 inclusive. This corresponds to a signed fixed-point representation of numbers with 12 bits for the fractional part and 20 bits for the integer part (totalling 32 bits), with the exception that the 32-bit value 0x80000000 is treated differently by SmileBasic: more information here.

The fixed-point system has some drawbacks; for instance, underflow: the expression 1*5000/5000 will give the result 1 just as you expect, but 1/5000*5000 (which is mathematically equivalent) will give the result 0; and overflow: the expression 99999/10*10 gives 9998.99951171875 (the small error of 1/2048 is due to rounding), but 99999*10/10 (again mathematically equivalent to the previous expression) generates an Overflow error. (Of course, the floating-point system has some drawbacks too; the thing is to be aware of what system is in use and its properties and pitfalls.)

A numeric literal may be expressed in SmileBasic V2 as a decimal value in the normal way; if the number cannot be represented exactly, it appears to be rounded towards zero to the nearest number it can represent (except, see 0.999995 (Numerical Value)). A numeric literal may also be expressed as &H (or &h) followed by an integer in hexadecimal (no more than 5 digits, including leading zeros), or &B or &b followed by an integer in binary (no more than 20 digits, including leading zeros).

The numeric data type also functions as the boolean data type: for example, the value between the IF and THEN keywords need not necessarily be just TRUE or FALSE, it can be any numeric value. A non-zero numeric value has the logical sense of TRUE, and only zero has the logical sense of FALSE. (This has the side-effect that CANCEL has the logical sense of TRUE.)


A string value in SmileBasic V2 is a list of ordered characters (each character may be selected from the set CHR$(0) to CHR$(255) inclusive), where the list may have any length between 0 and 256 inclusive.

The system can handle up to 4096 generated string values at any time; generating another string will yield an Out of memory error. A string is generated whenever a nonempty string literal is encountered while executing a statement; by string operations and functions such as + (concatenation) and STR$, and when any of the system string variables except MEM$ are read: so, for example, SAVE PRGNAME$ or PRINT "Hi" might fail, which you would not expect otherwise. A generated string that is no longer referenced by a variable name or array entry is removed from the count of 4096.

As an example, the program CLEAR:DIM A$(5000):FOR I=0 to 4999:A$(I)="String":NEXT will give an Out of memory error, because a new string is generated each iteration through the loop when the string literal is encountered, but the program CLEAR:STRING$="String":DIM A$(5000):FOR I=0 to 4999:A$(I)=STRING$:NEXT will not, because only one string value is ever generated, and all the entries in the array use the same string reference as STRING$.

A string literal may be expressed in SmileBasic V2 as a list of characters (excluding the " character), surrounded by " characters. The empty string is represented by the literal "". If a string literal is the last thing on a line of code, the closing " may be omitted.

Composite data typesEdit

SmileBasic V2 has just one composite data type, the array.


There are two types of array in SmileBasic V2, one for each of the primitive types: a numeric array and a string array. SmileBasic does not permit for array values to be expressed literally, they must be generated programmatically by declaring an array value (with DIM), then populating the array by assignment (unless the desired values are all the default value for the corresponding type: 0 for numeric arrays, the empty string for string arrays).

Arrays may be one-dimensional or two-dimensional. All array indices start at 0. A single array may have up to 262144 elements.

Arrays may only be declared once after a CLEAR command. They may not be resized, or deleted, before the next CLEAR.


No information for data types in SmileBasic V3.

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.