This is an old revision of the document!


Arithmetic expressions

When no parentheses are present, arithmetic expressions are evaluated from left to right, with multiplication and division having a higher priority than addition and subtraction.

Highest NOT, - (unary)
*, /, MOD
+, -
<, <=, >, =, >=, >
Lowest AND, OR, XOR

The arithmetic operators, +, -, *, and /, work in the expected fashion, however, the result of arithmetic on type BYTE, WORD or INT cannot have a fractional result. Therefore 5 / 2 evaluates as 2, not 2.5 (any fraction is always discarded). However, 5.0 / 2.0 evaluates as 2.5, because the presence of the decimal point tells the compiler that the numbers are FLOAT.

PRINT 5/2 ' Outputs 2
PRINT 5.0/2.0 ' Outputs 2.5