Arithmetic and functions
Operators, precedence, decimals, and every supported math function.
Operators
Use +, -, *, /, % (remainder), ^ or ** (power). Powers precede multiplication/division/remainder, which precede addition/subtraction. Powers associate to the right: 2^3^2 means 2^(3^2). Parentheses override this order. Unary signs and decimals work; normalization simplifies +- and --.
2d6+3
(d8+2)*3
2d20/2
d6^2
d20+1.5
One-argument functions
An argument can contain a full expression, including dice.
| Function | Effect | Example |
|---|---|---|
abs(x) |
Absolute value | abs(d6-4) |
ceil(x) |
Round upward | ceil(3d6/2) |
floor(x) |
Round downward | floor(3d6/2) |
round(x) |
Nearest integer, following Math.round | round(d20/2) |
sign(x) |
−1, 0, or 1 | sign(d20-10) |
sqrt(x) |
Square root | sqrt(16) |
exp(x) |
e to the power of x | exp(1) |
log(x) |
Natural logarithm | log(10) |
sin(x) |
Sine in radians | sin(d6) |
cos(x) |
Cosine in radians | cos(d6) |
tan(x) |
Tangent in radians | tan(d6) |
Two-argument functions
min(a,b) returns the smaller value, max(a,b) the larger, and pow(a,b) computes a power. These differ from the minN/maxN modifiers, which transform each face.
min(2d10,7)
max(d20,5)
pow(2,3)+d6
Division by zero and functions producing a non-finite result raise NON_FINITE_RESULT. Intermediate operations follow decimal12-v1; the final total has two decimal places.