Arithmetic Expressions

QLingo currently supports several arithmetic operations with the conventional order of precedence.

The operations, in order of priority, are mod, div, *, /, +, -, and &.

Syntax:

Arithmetic Expression

Description

* ,  / ,  - , and + signs

Perform arithmetic calculations

+ sign

Concatenates strings. "a" + "b"

& sign

Concatenates any type, while the result is a string.

"a" & 1 (= "a1"), 1 & 2 (= "12")

Mod or %sign

Perform modulo operations, using either “mod” or “%”,
for example:

5 mod 2 = 1

5 % 2 = 1

Any fractional part of a number is lost. 5.1 mod 2 = 1

Div

Concludes the round division answer. 5 div 2 = 2.
Any fractional part of a number is lost. 5.1 div 2 = 2

Examples:

Regular arithmetic:

5 * 3      =   15

5 / 2      =   2.5

5 Div 2    =    2

5 Mod 2    =    1

Concatenation:

"Joan" & " " & "Smith"    =    Joan Smith

56 & 4            =   564

#31/01/1973# & " Date"    =    31/01/1973 Date

The '+' sign between strings as concatenation:

"Joan" + " " + "Smith"    -    =    Joan Smith

The '+' and '-' signs between date and number to add/subtract days to/from a date:

The '-' sign between dates in order to get the difference in number of days:

#03/01/2002# - #01/01/2002#    =    2