Adds a numeric expression to a numeric variable.
Add x, y( assignment command)
% = x Add y( operator)
% = Add(i, j[,m,...])( function)
x:numeric variable
y:any numeric expression
i, j, m:integer expression
Add x, y adds the expression y to the value in variable x.
The operator i Add j and the function Add(i, j, …) return the sum of integer expressions. In case one of the parameters isn't an integer, it is converted to a 32-bit value first (using CInt).
Debug.Show
Dim b# = 1.5
Trace b# Add 3 // CInt(b#) + 3 = 5
Trace Add(b#, 3) // CInt(b#) + 3 = 5
Add b#, 3 : Trace b# // b# = 4.5
b# = 2.5
Trace b# Add 3 // CInt(b#) + 3 = 5
Trace Add(b#, 3) // CInt(b#) + 3 = 5
Add b#, 3 : Trace b# // b# = 5.5
Although the assignment command Add can be used with any numeric variable, the usage of integer variables is recommended in order to achieve the maximum optimization for speed.
Instead of Add x, y, you can use x = x + y, x := x + y, or x += y. When using integer variables Add doesn't test for overflow!
The Add(), Sub(), Mul() and Div() functions can be mixed freely with each other. For example
l% = Add(5 ^ 3, 4 * 20 - 3)
can be written
l% = Add(5 ^ 3, Sub(Mul(4, 20), 3))
+, -, *, /, \, Add, Sub, Mul, Div, ++, --, +=, -=, /= , *=, Operator Hierarchy
{Created by Sjouke Hamstra; Last updated: 24/06/2017 by James Gaite}