Expression Evaluation

ARMbasic can evaluate an expression as either an integer, string or floating point. The type of evaluation that is performed is determined by the first variable, constant or function in a statement when scanning from left to right. It is simple scan of left to right and () are ignored for determining the type of evaluation that will occur.





SINGLEtype = 1/2 ' results in 0.500000

INTEGERtype = 1/2 ' results in 0

functionCall ( 0.123 + INTEGERtype) ' passes a SINGLE type to functionCall

functionCall ( 123 + SINGLEtype ) ' passes an INTEGER to functionCall

if 1 = SINGLEtype*2 then print "true"            ' will not print true, as the expression is evaluated as integers

if 1.0 = SINGLEtype*2 then print "true"         ' will print true as 1.0 is a floating point constant and the expression is evaluated as float