The amis-formula package includes a variety of mathematical functions for numeric calculations.
Basic Arithmetic & Comparison
ABS(num): Absolute value.INT(num): Rounds down to the nearest integer.MOD(num, divisor): Remainder of division.POW(base, exponent): Base raised to the power of exponent.SQRT(num): Square root.PI(): Returns the constant $\pi$.RAND(): Returns a random float between 0 and 1 (changes on every calculation).
Aggregation Functions
These functions can accept multiple arguments (num1, num2, ...) or a single array ([num1, num2, ...]).
MAX(num1, ...): Returns the largest value.MIN(num1, ...): Returns the smallest value.SUM(num1, ...): Returns the sum of all values.AVG(num1, ...): Returns the average value.LARGE(array, k): Returns the $k$-th largest value in a dataset.
Rounding & Precision
ROUND(num[, numDigits = 2]): Rounds to specified decimal places.FLOOR(num[, numDigits = 2]): Rounds down to specified decimal places.CEIL(num[, numDigits = 2]): Rounds up to specified decimal places.
Statistical & Specialized
DEVSQ(num1, ...): Sum of squares of differences from the mean.AVEDEV(num1, ...): Mean absolute deviation from the arithmetic mean.HARMEAN(num1, ...): Harmonic mean.UPPERMONEY(num): Converts a number to Chinese uppercase currency characters.LAST(array): Returns the last element of an array.
// Examples
ABS(-5) // 5
SUM([1, 2, 3]) // 6
ROUND(3.14159, 2) // 3.14
RAND() * 100 // Random number between 0-100