Mathematical operators and functions perform operations on numbers. You can use them in
variable definitions, conditions, and actions.
Table 1. Mathematical operators
| Syntax |
Description |
Example |
- <number>
|
Makes a number negative. |
set decision to - the number of errors
|
<number> + <number>
|
Adds a number to another number. |
set decision to the base rental cost of car + 100
|
<number> - <number>
|
Subtracts a number from another number. |
if the number of 'items purchased' - the number of 'items returned' is more than 0
|
<number> / <number>
|
Divides a number by another number. If both numbers are integers, the result is also an
integer (the result of the division without the remainder). |
set decision to the number of 'items ordered' / the number of orders
|
<number> * <number>
|
Multiplies a number by another number. |
if the price of item * 'sales tax' is more than 100
|
Table 2. Mathematical functions
| Syntax |
Description |
Example |
lg(<number>)
|
Returns the base 10 logarithm of a number. |
set decision to lg('initial value')
|
ln(<number>)
|
Returns the natural logarithm (base e) of a number. |
set decision to ln('initial value')
|
max(<number>, <number>)
|
Returns the greater value. |
set decision to max(the age of customer, 20)
|
min(<number>, <number>)
|
Returns the smaller value. |
set decision to min(the age of customer, 20)
|
pow(<number>, <number>)
|
Returns the power of a number raised to the second argument. |
set decision to pow('initial value', 3)
|
round(<number>, <number>)
|
Rounds the first number to the number of decimal places that are given as second
argument. |
set decision to round('intermediate total', 2)
|
sqrt(<number>, <number>)
|
Returns the positive square root of a number. |
set decision to sqrt(side)
|