An expression must consist of either operands or operators. An operand is
either an integer (e.g. 12), a real number (e.g. 7.28), or a number in
scientific notation (e.g. 6.02e23, where the 'e' means 'times ten to the power
of'). The operators are listed in the table below.
Operators are evaluated in the order of their precedence. If two operators of equal precedence are adjacent (e.g. 3+5-1, or 3*5/2) they will be performed left-to-right. Parenthesis may be used to force operators of lesser precedence to be evaluated first (e.g. 5*(3+4) will perform the addition first).
Note: All trigonometric operators interpret its operand as an angle in radians.
Valid Operators | ||||
---|---|---|---|---|
Precedence | Operator | Description | Example | Example Result |
1 | + | Add | 1+1 | 2 |
- | Subtract | 3-1 (binary op) -4 (unary op) | 2 -4 | |
2 | * | Multiply | 2*5 | 10 |
/ | Divide | 7/2 | 3.5 | |
3 | ^ | Power: n^m means nm, or n to the power of m. | 2^4 | 16 |
d | Dice Roll: ndm means roll n m-sided dice and add the results together Note that n >= 1 and m >= 2. if n is not present, an implicit 1 is assumed. | 3d6 | Varies from 3 to 18 | |
root | n root m means the mth root of n. Note that m = 2 is the same as the sqrt operator, and that m = 3 is the cube root of n. | 9 root 2 | 3 | |
P | Permutation: nPk is the number of permutations of n things taken k at a time. Note that n and k must be integers, that n >= 0 and n >= k >= 0. | 6P2 | 30 | |
C | Combination: nCk is the number of combinations of n things taken k at a time. Note that n and k must be integers, that n >= 0 and n >= k >= 0. | 8C3 | 56 | |
4 | sqrt | Square root | sqrt 5 | 2.236068 |
log | Common (base-10) logarithm. | log 200 | 2.301029996 | |
ln | Natural (Napierian, or base-e) logarithm. | ln 20 | 2.99573227 | |
exp | Exponential of x, or ex. | exp 5 | 148.41315910 | |
sin | Sine of x, where x is in radians. | sin 0.523598756 | 0.5 | |
cos | Cosine of x, where x is in radians. | cos 1.04719755 | 0.5 | |
tan | Tangent of x, where x is in radians. | tan 0.7853981634 | 1.0 | |
csc | Cosecant of x, where x is in radians. | csc 0.523598756 | 2.0 | |
sec | Secant of x, where x is in radians. | sec 1.04719755 | 2.0 | |
cot | Cotangent of x, where x is in radians. | cot 0.7853981634 | 1.0 | |
vers | Versine of x, where x is in radians. | |||
covers | Coversine of x, where x is in radians. | |||
hav | Haversine of x, where x is in radians. | |||
exsec | Exsecant of x, where x is in radians. | |||
asin | Arcsine, or inverse sine, of x. The result will be in radians. | asin 0.5 | 0.523598756 | |
acos | Arccosine, or inverse cosine, of x. The result will be in radians. | acos 0.8660254 | 0.523598756 | |
atan | Arctangent, or inverse tangent, of x. The result will be in radians. | atan 1.0 | 0.7853981634 | |
avers | Arc-versine, or inverse versine, of x. The result will be in radians. | |||
acovers | Arc-coversine, or inverse coversine, of x. The result will be in radians. | |||
ahav | Arc-haversine of, or inverse haversine, x. The result will be in radians. | |||
aexsec | Arc-exsecant of, or inverse exsecant, x. The result will be in radians. | |||
sinh | Hyperbolic sine of x. | sinh 1.0 | 1.1752012 | |
cosh | Hyperbolic cosine of x. | cosh 1.0 | 1.5430806 | |
tanh | Hyperbolic tangent of x. | tanh 1.0 | 0.761594156 | |
csch | Hyperbolic cosecant of x. | csch 1.0 | 0.85091813 | |
sech | Hyperbolic secant of x. | sech 1.0 | 0.64805247 | |
coth | Hyperbolic cotangent of x. | coth 1.0 | 1.313035285 | |
5 | pi | The constant pi | pi | 3.14159265359 |
e | The constant e, base of the natural logarithms | e | 2.71828182846 | |
! | Factorial: n! = n*(n-1)*(n-2)*...*2*1 | 5! | 120 |