Home, Up: Operators and Constants
2-argument operators replace their arguments (two values to their left) and themselves with the result of the operation.
The first argument (left to right) of a 2-argument operator is here 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": 5 2 + = 7
- means "subtract b from a": 5 2 - = 3
* means "multiply a with b": 5 2 * = 10
/ means "divide a by b": 5 2 / = 2.5
// means "relative difference, a minus b divided by b" (returns a if b is zero): 12 10 // = 0.2
\ means "integer division a by b" (absolute value of a by b is rounded down to the next integer): -5 2 \ = -2
IMOD means "remainder, a modulo b" (a and b must be integer and have the same sign): 5 MOD 2 = 1
MOD means "remainder, a modulo b" (a and b must have the same sign, real numbers permitted): 5.5 2 MOD = 1.5
BIN means "binomial coefficient" (a must be positive integer, b must be 0 or positive integer): 6 3 BIN = 20
^ means "a to the power of b": 3 4 ^ = 81
ROOT means "bth root of a" (a must not be negative): 81 4 ROOT = 3
LOG^ means "logarithm of a, base b" (a must be positive, b must be > 1): 81 3 LOG^ = 4
% means "b % of a": 50 20 % = 10
%+ means "a plus b percent": 50 20 %+ = 60
%- means "a mins b percent": 50 20 %- = 40
%N means "net amount, if a is gross amount including b percent": 60 20 %N = 50
%A means "agio amount, if a is gross amount including b percent": 60 20 %A = 10
%? means "how many percent of a is b?": 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 abs(a) is less than b, otherwise a"
UPLIMIT means "a if not larger than b, otherwise b (b is the upper limit)"
LOLIMIT means "a if not lower than b, otherwise b (b is the lower limit)"
ABSLIMIT means "b is limit for absolute value of a (result is a, but not higher than b or lower than -b)"
Do not confuse these operators with the RAND pseudo constant!
RANDINT means "random integer, within the range of a to b" (one or both arguments can be negative, but a must be less 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 less than b"
<= means "true if a is less than b, or if a and b are equal"
>> means "true if a is greater than b"
>= means "true if a is greater than b, or if a and b are equal"
MULTIPLE means "a divided by b if a is positive multiple of b" (a and b must be integer, false if a = 0 or 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)"
The result of // is set to 0 if its absolute value is less 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 do 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.
Do not confuse the compare operator == (same as EQUAL) with the == command!
Home, Up: Operators and Constants, Prev: 1-Argument Operators, Next: n-Argument Operators