You can use arithmetic math functions in NetScript in Optimizely Analytics.
Basic operations
This section lists the basic math operations you can perform using NetScript.
number + number
Returns the sum of the inputs.
Function:
number + numberData type: number
Example:
5 + 7Result:
12number - number
Returns the difference between the inputs.
Function:
number - numberData type: number
Example:
13-10Result:
3number * number
Returns the product of the inputs.
Function:
number * numberData type: number
Example:
7 * 8Result:
56number / number
Returns the division of the inputs.
Function:
number / numberData type: number
Example:
84 / 4Result:
21number ^ number
Returns number1 raised to the power of number2.
Function:
number ^ numberData type: number
Example:
2 ^ 9Result:
512Advanced operations
This section lists the advanced math operations you can perform using NetScript.
abs(number)
Returns the absolute value of a numeric expression.
Function:
abs(number)Data type: number
Example:
abs(-2)Result:
2floor(number)
Rounds the number down to the nearest integer.
Function:
floor(number)Data type: number
Example:
floor(17.36)Result:
17round(number[, N])
Rounds the number to the given precision (N), which is 0 by default. Precision value can be positive or negative and indicates the number of decimal places displayed in the rounded number.
Function:
round(number[, <N>])Data type: number
Example:
round(23.45)
round(23.45, 0)
round(23.45, 1)
round(23.45, -1)Result:
23
23
23.5
20truncate(number[, N])
Rounds the number down to the given precision (N), which is 0 by default.
Function:
truncate(number[, <N>])Data type: number
Example:
truncate(23.45)
truncate(23.45, 0)
truncate(23.45, 1)
truncate(23.45, -1)Result:
23
23
23.4
20sqrt(number)
Returns the square root (full-precision decimal) of the input.
Function:
sqrt(number)Data type: number
Example:
sqrt(64)Result:
8least(number(, number)*)
Returns whichever number has the smallest value.
Function:
least(number(, number)*)Data type: number
Example:
least(7(, 23)*)Result:
7greatest(number(, number)*)
Returns whichever number has the largest value.
Function:
greatest(number(, number)*)Data type: number
Example:
greatest(7(, 23)*)Result:
23
Please sign in to leave a comment.