+ is the BASIC operator for addition.
If the result of adding two numbers has a magnitude greater than SmileBasic can represent, the system generates an
Overflow error. It also generates an
Overflow error when the result is a particular value that is within SmileBasic's capacity to represent: 524287.999755859375.
As well as working on numbers, it also works to concatenate strings(*). The result of adding two strings is a single string that appends the second operand to the first.
One aspect of SmileBasic V2 is that "scratch" calculations in evaluating string expressions share the memory used for variable storage, which is limited to 4096 strings. This means that the null operation of appending an empty string (e.g.
A$+"") can cause an
Out of memory error, and an expression like
(A$+B$)+(C$+D$) can cause an
Out of memory error where the expression
A$+B$+C$+D$ does not (even if they are all the empty string!). Also, when string concatenation causes an
Out of memory error, a memory leak occurs.
(*) According to http://smileboom.com/special/ptcm2/html_bug.php, the string concatenation operator may sometimes give incorrect results.