math
Plain math over numbers: minimum, maximum, absolute difference and integer square root.
load mathHelpers
Section titled “Helpers”| Helper | Returns | Description |
|---|---|---|
| @math:absDiff | number | Absolute difference |
| @math:exp | number | e raised to a wad-scaled power, in wad (1e18) fixed point. Continuous growth over a period: a rate r compounded continuously multiplies a balance by exp(r). |
| @math:ln | number | The natural logarithm of a wad-scaled value, in wad (1e18) fixed point. The inverse of exp: it turns a growth factor back into the rate that produced it. |
| @math:log2 | number | The base-2 logarithm of a whole number, rounded down — the position of its highest set bit, so it also gives a bit length. Undefined at zero. |
| @math:max | number | Maximum of two or more values. |
| @math:min | number | Minimum of two or more values. |
| @math:pow | number | Raise a fixed-point value to a whole power, where one unit is base (1e18 by default, 1e27 for a ray). Compounding a per-period rate over N periods is pow(unit + rate, N). |
| @math:sqrt | number | Integer square root (floor). |