Arithmetic Statements
Note
Starting on LDPL 5.2.1, all arithmetic statements also accept an IN-first synonym. This
means that in addition to writing ADD 1 AND 2 IN myVar, you can now also write
IN myVar ADD 1 AND 2.
IN _ SOLVE _
The IN - SOLVE statement will solve a simple arithmetic expression and place the result in a NUMBER variable. Only +, -, /, * operators, NUMBER values, and TEXT values can be used in a MATH-EXPRESSION. Other LDPL arithmetic functions, like floor and modulo, are not supported by this statement and should be used as standalone statements. TEXT values will be implicitly converted to NUMBERs using the same algorithm as the one used in store _ in _.
Spaces must be used to separate numbers, variables and operators.
As in actual arithmetic, * and / have higher precedence than + and - , while parens () can be used to group expressions.
Syntax:
1 | |
Example:
1 | |
Will set the value of myNumVariable to 2.
Area of Circle:
1 2 3 4 5 6 7 8 9 10 | |
Outputs:
1 2 | |
FLOOR
The FLOOR statement rounds down the value of NUMBER-VAR to the nearest lower integer.
Syntax:
1 | |
CEIL
The CEIL statement rounds up the value of NUMBER-VAR to the nearest higher integer.
Syntax:
1 | |
FLOOR _ IN _
The FLOOR _ IN _ statement rounds down the value of NUMBER-VAR to the nearest lower integer
and stores the result in a NUMBER variable.
Syntax:
1 | |
CEIL _ IN _
The CEIL _ IN _ statement rounds up the value of NUMBER-VAR to the nearest higher integer
and stores the result in a NUMBER variable.
Syntax:
1 | |
ADD _ AND _ IN _
The ADD statement adds two NUMBER values and stores the result in a NUMBER variable.
Syntax:
1 | |
SUBTRACT _ FROM _ IN _
The SUBTRACT statement subtracts two NUMBER values and stores the result in a NUMBER variable.
Syntax:
1 | |
MULTIPLY _ BY _ IN _
The MULTIPLY statement multiplies two NUMBER values and stores the result in a NUMBER variable.
Syntax:
1 | |
DIVIDE _ BY _ IN _
The DIVIDE statement divides two NUMBER values and stores the result in a NUMBER variable.
Syntax:
1 | |
MODULO _ BY _ IN _
The MODULO statement calculates the remainder of the modulo operation between two NUMBER values and stores the result in a NUMBER variable.
Syntax:
1 | |
GET RANDOM IN _
The GET RANDOM statement stores a random value between 0 (inclusive) and 1 (noninclusive) in a NUMBER variable.
Syntax:
1 | |
RAISE _ TO _ IN _
The RAISE <a> TO <b> IN <c> statement calculates a^b and stores the result in c.
Syntax:
1 | |
LOG _ IN _
The LOG _ IN _ statement calculates the natural logarithm of a NUMBER and stores the result in a NUMBER variable.
Syntax:
1 | |
SIN _ IN _
The SIN _ IN _ statement calculates the sine of a NUMBER and stores the result in a NUMBER variable.
Syntax:
1 | |
COS _ IN _
The COS _ IN _ statement calculates the cosine of a NUMBER and stores the result in a NUMBER variable.
Syntax:
1 | |
TAN _ IN _
The TAN _ IN _ statement calculates the tangent of a NUMBER and stores the result in a NUMBER variable.
Syntax:
1 | |
1 2 3 4 5 6 7 8 | |
DECREMENT _
The DECREMENT _ statement subtracts 1 from the value of a NUMBER variable.
Syntax:
1 | |