Home, Up: Operators and Constants
2-argument operators replace their arguments (two values to their left) and themselves with the result of the operation.
In this documentation the first argument (from left to right) of a 2-argument operator is called a, the second argument is called b.
On this page:
Arithmetic Operators, Percentage Operators, Rounding and Limiting Operators, Random Number Operators, Compare Operators, Unit Conversion Operator, Notes.
+ means "add a and b" -- example: 5 2 + = 7
- means "subtract b from a" -- example: 5 2 - = 3
* means "multiply a with b" -- example: 5 2 * = 10
/ means "divide a by b" -- example: 5 2 / = 2.5
// means "relative difference, a minus b divided by b" (returns a if b is zero) -- example: 12 10 // = 0.2
\ means "integer division a by b" (absolute value of a by b is rounded down to the next integer) -- example: -5 2 \ = -2
IMOD means "remainder, a modulo b" (a and b must be integer and have the same sign) -- example: 5 IMOD 2 = 1
MOD means "remainder, a modulo b" (a and b must have the same sign, real numbers are permitted) -- example: 5.5 2 MOD = 1.5
BIN means "binomial coefficient" (a must be positive integer, b must be 0 or positive integer) -- example: 6 3 BIN = 20
^ means "a to the power of b" -- example: 3 4 ^ = 81
ROOT means "bth root of a" (a must be positive) -- example: 81 4 ROOT = 3
LOG^ means "logarithm of a, base b" (a must be positive, b must be > 1) -- example: 81 3 LOG^ = 4
% means "b % of a" -- example: 50 20 % = 10
%+ means "a plus b percent" -- example: 50 20 %+ = 60
%- means "a minus b percent" -- example: 50 20 %- = 40
%N means "net amount, if a is gross amount including b percent" -- example: 60 20 %N = 50
%A means "agio amount, if a is gross amount including b percent" -- example: 60 20 %A = 10
%? means "how many percent of a is b?" -- example: 50 10 %? = 20
ROUND means "round a to b digits after decimal point, if b is 0 then round to integer, if b is negative then round to b zeros before decimal point" (b can be from -9 to 15)
ROUNDS means "round a to b significant digits" (b can be from 1 to 17)
GATE means "zero if absolute value of a is lower than b, otherwise a"
UPLIMIT means "a if it is not higher than b, otherwise b (b is the upper limit)"
LOLIMIT means "a if it is not lower than b, otherwise b (b is the lower limit)"
ABSLIMIT means "a if its absolute value is lower than b, otherwise b or -b depending on the sign of a" (b must be positive)
Do not confuse these operators with the RAND pseudo constant!
RANDINT means "random integer in the range of a to b" (a and b must be integers, one or both can be negative, but a must be lower than b)
RANDND means "normal distributed random number" (a is the mean, b the standard deviation, 0 0 means standard normal distribution, same as 0 1)
The result of a compare operator (except MULTIPLE) is 1 if the condition is met (true), and 0 if it is not met (false).
In most cases compare operators will be used in scripts, and their arguments will be variables and/or numerical expressions.
== or EQUAL means "true if a and b are equal"
<> or UNEQUAL means "true if a and b are not equal"
<< means "true if a is lower than b"
<= means "true if a is lower than b, or if a and b are equal"
>> means "true if a is higher than b"
>= means "true if a is higher than b, or if a and b are equal"
MULTIPLE means "a divided by b if a is a positive multiple of b, otherwise 0" (a and b must be integer, 0 if a and b do not have the same sign)
Currently there is only one 2-argument unit conversion operator.
:MSDEC means "convert a minutes and b seconds to decimal (hours or degrees)" -- example: 30 0 :MSDEC = 0.5
The result of // is set to 0 if its absolute value is smaller than 1e-16. This is useful as a loop exit condition in a script.
If the threshold value for GATE is zero, it is taken to be 1e-16 (an actual gate threshold of 0 would make no sense).
Unlike GATE, UPLIMIT and LOLIMIT as well as the compare operators observe the signs of the arguments, -5 is lower than 3.
The compare operators EQUAL or ==, UNEQUAL or <>, <<, <=, >> and >= observe the zero threshold to decide equality -- see page The Zero Threshold in chapter "Numbers".
Do not confuse the compare operator == (same as EQUAL) with the == command, see page Result Commands in chapter "Results".
For notes on normal distributed random numbers see page Technical Notes in the Appendix.
Home, Up: Operators and Constants, Prev: 1-Argument Operators, Next: n-Argument Operators