Numeric and Math Functions
AMPS includes the following functions for working with numbers.
ABS
ABS
ABS(number)
Returns the absolute value of a number.
Parameters
number: The number to find the absolute value of.
Returns
The absolute value of the number.
GREATEST
GREATEST
GREATEST(number, [number, ...])
Returns the largest of the provided values.
Parameters
number: A list of numbers to compare.
Returns
The largest of the provided values.
LEAST
LEAST
LEAST(number, [number, ...])
Returns the smallest of the provided values.
Parameters
number: A list of numbers to compare.
Returns
The smallest of the provided values.
CEILING
CEILING
CEILING(number)
Returns the value rounded upward to the next greatest integer.
Parameters
number: The number to round.
Returns
The rounded-up integer as a double. Returns an integer unchanged (still converts to double).
FLOOR
FLOOR
FLOOR(number)
Returns the value rounded downward to the next lower integer.
Parameters
number: The number to round.
Returns
The rounded-down integer as a double. Returns an integer unchanged (still converts to double).
EXP
EXP
EXP(exponent)
Returns e raised to the power of the provided exponent.
Parameters
exponent: The exponent to use.
Returns
The value of e raised to the power of the exponent.
LN
LN
LN(number)
Returns the natural logarithm of the provided number.
Parameters
number: The number to operate on.
Returns
The natural logarithm of the number. Returns NaN if number is outside the domain of logarithmic functions.
LOG2
LOG2
LOG2(number)
Returns the base-2 logarithm of the provided number.
Parameters
number: The number to operate on.
Returns
The base-2 logarithm of the number. Returns NaN if number is outside the domain of logarithmic functions.
LOG10
LOG10
LOG10(number)
Returns the base-10 logarithm of the provided number.
Parameters
number: The number to operate on.
Returns
The base-10 logarithm of the number. Returns NaN if number is outside the domain of logarithmic functions.
POWER
POWER
POWER(base, exponent)
Returns the value of base raised to the power of exponent.
Parameters
base: The base number.exponent: The exponent.
Returns
The value of the base raised to the power of the exponent. POSIX-compliant edge cases.
SQRT
SQRT
SQRT(number)
Returns the square root of the provided number.
Parameters
number: The number to find the square root of.
Returns
The square root of the number. Returns NaN if number is outside the domain of the square root function.
RADIANS
RADIANS
RADIANS(degrees)
Returns the provided number converted from degrees to radians.
Parameters
degrees: The number in degrees.
Returns
The number converted to radians.
DEGREES
DEGREES
DEGREES(radians)
Returns the provided number converted from radians to degrees.
Parameters
radians: The number in radians.
Returns
The number converted to degrees.
SIGN
SIGN
SIGN(number)
Returns the sign of the provided number.
Parameters
number: The number to check.
Returns
If the number is less than 0, returns -1. If the number is greater than 0, returns 1. Otherwise, the number is 0 and the function returns 0.
ROUND
ROUND
ROUND(number, [decimal_places])
Returns a number rounded to the specified number of decimal places.
Parameters
number: The number to round.decimal_places: Optional. The number of decimal places to round to. Defaults to 0. Can be positive or negative.
Returns
The rounded number.
WIDTH_BUCKET
WIDTH_BUCKET
WIDTH_BUCKET(expression, min, max, bucket_count)
The bucket_count argument specifies the number of buckets to create over the range defined by min and max. min is inclusive, while max is not. The value from expression is assigned to a bucket, and the function returns a corresponding bucket number.
Parameters
expression: The expression to evaluate.min: The minimum value of the range.max: The maximum value of the range.bucket_count: The number of buckets to create.
Returns
The bucket number. When expression falls outside the range of buckets, the function returns either 0 or max + 1, depending on whether expression is lower than min or greater than or equal to max.
Trigonometric Functions
ACOS
ACOS
ACOS(number)
Returns the arccosine of the provided number.
Parameters
number: The number to operate on.
Returns
The arccosine of the number. Returns NaN if number is outside the domain of the arccosine function.
ASIN
ASIN
ASIN(number)
Returns the arcsine of the provided number.
Parameters
number: The number to operate on.
Returns
The arcsine of the number. Returns NaN if number is outside the domain of the arcsine function.
ATAN
ATAN
ATAN(number)
Returns the arctangent of the provided number.
Parameters
number: The number to operate on.
Returns
The arctangent of the number.
ATAN2
ATAN2
ATAN2(y, x)
Returns the arctangent of the provided numbers. POSIX-compliant edge cases.
Parameters
y: The y-coordinate.x: The x-coordinate.
Returns
The arctangent of the numbers.
COS
COS
COS(number)
Returns the cosine of the provided number.
Parameters
number: The number to operate on.
Returns
The cosine of the number.
COSH
COSH
COSH(number)
Returns the hyperbolic cosine of the provided number.
Parameters
number: The number to operate on.
Returns
The hyperbolic cosine of the number.
COT
COT
COT(number)
Returns the cotangent of the provided number.
Parameters
number: The number to operate on.
Returns
The cotangent of the number. Returns NaN if number is 0.
SIN
SIN
SIN(number)
Returns the sine of the provided number.
Parameters
number: The number to operate on.
Returns
The sine of the number.
SINH
SINH
SINH(number)
Returns the hyperbolic sine of the provided number.
Parameters
number: The number to operate on.
Returns
The hyperbolic sine of the number.
TAN
TAN
TAN(number)
Returns the tangent of the provided number.
Parameters
number: The number to operate on.
Returns
The tangent of the number.
TANH
TANH
TANH(number)
Returns the hyperbolic tangent of the provided number.
Parameters
number: The number to operate on.
Returns
The hyperbolic tangent of the number.