Numeric Functions
AMPS includes the following functions for working with numbers.
ABS
number
Returns the absolute value of a number.
For example, the following filter will be TRUE when the difference between /a
and /b
is greater than 5, regardless of whether /a
or /b
is larger.
GREATEST
list of numbers to compare
Returns the largest of the provided numbers, or NaN
if no argument is a number.
LEAST
list of numbers to compare
Returns the smallest of the provided numbers, or NaN
if no argument is a number.
CEILING
number to round
Returns the value rounded upward to the next greatest integer. Returns an integer unchanged.
FLOOR
number to round
Returns the value rounded downward to the next lower integer. Returns an integer unchanged.
EXP
exponent to use
Returns e raised to the power of the provided exponent.
LN
number
Returns the natural logarithm of the provided number.
LOG2
number
Returns the base-2 logarithm of the provided number.
LOG10
number
Returns the base-10 logarithm of the provided number.
POWER
base, exponent
Returns the value of base raised to the power of exponent.
SQRT
number
Returns the square root of the provided number.
COS
number
Returns the cosine of the provided number.
ACOS
number
Returns the arcosine of the provided number.
SIN
number
Returns the sine of the provided number.
SINH
number
Returns the hyperbolic sine of the provided number.
ASIN
number
Returns the arcsine of the provided number.
COSH
number
Returns the hyperbolic cosine of the provided number.
COT
number
Returns the cotangent of the provided number.
ATAN
number
Returns the arctangent of the provided number.
ATAN2
number, number
Returns the arctangent of the provided numbers.
TAN
number
Returns the tangent of the provided number.
TANH
number
Returns the hyperbolic tangent of the provided number.
MD5
string
Returns the MD5 checksum of the provided string.
RADIANS
number
Returns the provided number converted from degrees to radians.
DEGREES
number
Returns the provided number converted from radians to degrees.
SIGN
number
Returns the sign of the provided number.
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
number, [number of decimal places]
Returns a number rounded to the specified number of decimal places.
The number of decimal places is optional. When not provided, the number defaults to 0.
The number of decimal places can be positive or negative. When the number is positive, the number specifies the number of digits to the right of the decimal place to round at. When the number is negative, the number specifies the number of digits to the left of the decimal place to round at.
For example, you could use the following expression in a view to limit the precision of the /price
field of the source topic to 2 decimal places.
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.
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.
Last updated