Mathematical Functions
RTR provides several built-in mathematical functions for performing common calculations.
min
Returns the smallest value among the provided arguments.
min(5, 3, 8); /* Returns 3 */
min(-1, -5, 0); /* Returns -5 */
max
Returns the largest value among the provided arguments.
max(5, 3, 8); /* Returns 8 */
max(-1, -5, 0); /* Returns 0 */
abs
Returns the absolute value of a number.
abs(-5); /* Returns 5 */
abs(3.14); /* Returns 3.14 */
round
Rounds a number to the nearest integer.
round(3.7); /* Returns 4 */
round(3.2); /* Returns 3 */
round(-3.7); /* Returns -4 */
floor
Rounds a number down to the nearest integer.
floor(3.7); /* Returns 3 */
floor(3.2); /* Returns 3 */
floor(-3.7); /* Returns -4 */
ceil
Rounds a number up to the nearest integer.
ceil(3.7); /* Returns 4 */
ceil(3.2); /* Returns 4 */
ceil(-3.7); /* Returns -3 */
sqrt
Returns the square root of a number.
sqrt(16); /* Returns 4 */
sqrt(2); /* Returns 1.4142135623730951 */
Last updated