Maths provides some definitions of common mathematical procedures.
Note that "maths" should not be used with "numbers" from IPL, as the definitions of various procedures differ.
ceiling (n)
Ceiling returns the smallest integer value not smaller than n.
For example:
ceiling(2.5) => 3 ceiling(-3.5) => -3
Parameters:
clamp (n, min_value, max_value)
Clamp ensures number is in range [min_value, max_value], returning min_value if number < min_value or max_value if number > max_value.
For example:
clamp(3, 5, 10) => 5 clamp(12, 5, 10) => 10 clamp(7, 5, 10) => 7
Parameters:
floor (n)
Floor returns the largest integer value not larger than n.
For example:
floor(2.5) => 2 floor(-3.5) => -4
Parameters:
maths_truncate (n)
Truncate returns the integer value closest to n whose absolute value is no larger than n.
Note, name to avoid conflict with Unicon's 'truncate' procedure.
For example:
maths_truncate(2.5) => 2 maths_truncate(-3.5) => -3
Parameters:
round (n)
Round returns the closest integer to n, rounding to even where n is half-way between two integers.
For example:
round(2.5) => 2 round(-3.5) => -4
Parameters: