7.01 Arithmetic Operations

Arithmetic Operations

Exponentiation
^
Exponentiation
Multiplication/Division Operations
*, /, \
Multiplication, Division, Integer Division
% or MOD
Remainder (equivalent to a=int(a), b=int(b), a-b*(a/b))
The sign of the result is the same as the dividend (the number being divided).
MDL
Modulus (a%b+b*(sgn(a)<>sgn(b)))
The sign of the result is the same as the divisor.
Addition/Subtraction Operations
+, -
Addition/Concatenation, Subtraction

Number Formats

&h or 0x
Prefix for hexadecimal constant (0x1F, &h3C)
&o or 0o
Prefix for octal constant (0o33, &o33)
&b or 0b
Prefix for binary constant (0b1010, &b1110)

Increment and Decrement

The ++ and -- operators are used to increase or decrease the value of a variable by 1.

x = 4
x++             // x <- x + 1 = 5
x--             // x <- x - 1 = 4

The increment and decrement operators do not work within expressions. To assign a value within an expression use the LET function.

y = x++         // ERROR
y = let(x, x++) // works

To be implemented. When used within an expression, these operators will be treated the same as the LET function.

Extended Assignment

The generic #= operators are used to perform an evaluation using a source varaible and then assign the result of the evaluation back to the same variable. # is any character of -+/\*%&| or the power operator **.

x += 4          // x <- x + 4
x *= 4          // x <- x * 4

These operators do not work within expressions. To assign a value within an expression use the LET function.

z = (y += 4)+5  // ERROR
z = let(y, y + 4) + 5 // works

To be implemented. When used within an expression, these operators will be treated the same as the LET function.


lynplex/lp0701.txt · Last modified: 2012/09/08 15:11 (external edit)