Skip to main content

Numeric Functions

AMPS includes the following functions for working with numbers.

FunctionParametersDescription
ABSnumber

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.

ABS(/a - /b) > 5
GREATESTlist of numbers to compare

Returns the largest of the provided numbers, or NaN if no argument is a number.

GREATEST(/requestedQty, /availableQty, /reserveQty)
LEASTlist of numbers to compare

Returns the smallest of the provided numbers, or NaN if no argument is a number.

LEAST(/requestedQty, /availableQty, /reserveQty)
CEILINGnumber to round

Returns the value rounded upward to the next greatest integer. Returns an integer unchanged.

CEILING(/estimatedDelta)
FLOORnumber to round

Returns the value rounded downward to the next lower integer. Returns an integer unchanged.

FLOOR(/estimatedReturn)
EXPexponent to use

Returns e raised to the power of the provided exponent.

EXP(3.14)
LNnumber

Returns the natural logarithm of the provided number.

LN(/time)
LOG2number

Returns the base-2 logarithm of the provided number.

LOG2(/recordSize)
LOG10number

Returns the base-10 logarithm of the provided number.

LOG10(/displayData)
POWERbase, exponent

Returns the value of base raised to the power of exponent.

POWER(/number, 3)
SQRTnumber

Returns the square root of the provided number.

SQRT(2304)
COSnumber

Returns the cosine of the provided number.

COS(/x)
ACOSnumber

Returns the arcosine of the provided number.

ACOS(/x)
SINnumber

Returns the sine of the provided number.

SIN(/x)
SINHnumber

Returns the hyperbolic sine of the provided number.

SINH(/x)
ASINnumber

Returns the arcsine of the provided number.

ASIN(/x)
COSHnumber

Returns the hyperbolic cosine of the provided number.

COSH(/x)
COTnumber

Returns the cotangent of the provided number.

COT(/x)
ATANnumber

Returns the arctangent of the provided number.

ATAN(/x)
ATAN2number, number

Returns the arctangent of the provided numbers.

ATAN2(/y,/x)
TANnumber

Returns the tangent of the provided number.

TAN(/x)
TANHnumber

Returns the hyperbolic tangent of the provided number.

TANH(/x)
MD5string

Returns the MD5 checksum of the provided string.

MD5(/data)
RADIANSnumber

Returns the provided number converted from degrees to radians.

RADIANS(/deg)
DEGREESnumber

Returns the provided number converted from radians to degrees.

DEGREES(/rad)
SIGNnumber

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.

SIGN(/result)
ROUNDnumber, [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.

ROUND(/price, 2) AS /price
UUID7

Generates a unique identifier (UUID) in the version 7 format specified by RFC 9562. The identifier is returned as a formatted string.

WIDTH_BUCKETexpression, 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.

WIDTH_BUCKET(/percentage, 0, 100, 10) AS /displayBar