Data types

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

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

Numeric
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  will give the result   just as you expect, but   (which is mathematically equivalent) will give the result  ; and overflow: the expression   gives   (the small error of 1/2048 is due to rounding), but   (again mathematically equivalent to the previous expression) generates an   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. A numeric literal may also be expressed as  (or  ) followed by an integer in hexadecimal.

The numeric data type also functions as the boolean data type: for example, the value between the  and   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.)

String
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.

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.

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

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.

v3
No information for data types in SmileBasic V3.