# Math Filters

Math filters are various operations in Xano to perform math and calculations. Like all filters you can chain math filters together and nest them inside one another to perform order of operations.

• abs - Returns the absolute.

• acos - Calculates the arc cosine of the supplied value in radians.

• acosh - Calculates the inverse hyperbolic cosine of the supplied value in radians.

• asin - Calculates the arc sine of the supplied value in radians..

• asinh - Calculates the inverse hyperbolic sine of the supplied value in radians.

• atan - Calculates the arc tangent of the supplied value in radians.

• atanh - Calculates the inverse hyperbolic tangent of the supplied value in radians.

• bitwise_and - Bitwise AND 2 values together and return the answer.

• bitwise_or - Bitwise OR 2 values together and return the answer.

• bitwise_xor - Bitwise XOR 2 values together and return the answer.

• ceil - Round a decimal up to its integer equivalent.

• cos - Calculates the cosine of the supplied value in radians.

• divide - Divide 2 values together and return the answer.

• exp - Returns the exponent of mathematical expression "e".

• floor - Round a decimal down to its integer equivalent.

• array_max - Returns the max of the values of the array.

• array_min - Returns the min of the values of the array.

• modulus- Modulus 2 values together and return the answer.

• min - Return the min of any two values

• max - Return the max of any two values

• multiply - Multiply 2 values together and return the answer.

• number_format - Format a number with flexible support over decimal places, thousands separator, and decimal separator.

• pow - Returns the value raised to the power of exp.

• product - Returns the product of the values of the array.

• round - Round a decimal with optional precision.

• sin - Calculates the sine of the supplied value in radians.

• sqrt - Returns the square root of the value

• subtract - Subtract 2 values together and return the answer.

• sum - Returns the sum of the values of the array.

• tan - Calculates the tangent of the supplied value in radians.

abs(x)

Returns the absolute value of a number

Ex: `abs(-5) -> 5`

Inputs: `x` (numeric) A single number

Output: Outputs the absolute value of the input number

acos(x)

Calculates the arc cosine of the supplied value in radians.

Example: Find the arc cosine of 0.5: `acos(0.5)` -> `1.0471975511965976`

Inputs: `x` (numeric) A single number in the range [-1,1]

Output: Outputs the arc cosine of the input value in radians

acosh(x)

Calculates the inverse hyperbolic cosine of the supplied value in radians.

Example: Find the inverse hyperbolic cosine of 2: `acosh(2)` -> `1.3169578969248166`

INPUTS: `x` (numeric) A single number

OUTPUT: Outputs the inverse hyperbolic cosine of the input value

Ex: `add(5,7)` -> `12`

INPUTS: `x` (numeric), `y`(numeric) Two Numbers

OUTPUT: Outputs the sum of x and y

asin(x)

Calculates the arc sine of the supplied value in radians

Ex: `asin(0.5)` -> `0.5235987755982989`

INPUTS: `x` (numeric) A single number

OUTPUT: Outputs the arc sine of the input value in radiansa

asinh(x)

Calculates the inverse hyperbolic sine of the supplied value

Ex: `asinh(0.5)` -> `0.48121182505960347`

INPUTS: `x` (numeric) A single number

OUTPUT: Outputs the inverse hyperbolic sine of the input value

atan(x)

Calculates the arc tangent of the supplied value in radians

Ex: `atan(1)`-> `0.7853981633974483`

INPUTS: `x` (numeric) A single number

OUTPUT: Outputs the arc tangent of the input number in radianspa

atanh(x)

Calculates the inverse hyperbolic tangent of the supplied value in radians

Ex: `atanh(0.5)` -> `0.5493061443340548`

INPUTS: `x` (numeric) A single number

OUTPUT: Outputs the inverse hyperbolic tangent of the input number in radians

bitwise_and(x, y)

Bitwise AND 2 values together and return the answer

Ex: `bitwise_and(10, 2)` -> `2`

INPUTS: `x` (numeric), `y` (numeric) Two numbers

OUTPUT: Outputs the result of bitwise AND operation on the input numbers

bitwise_or(x, y)

Bitwise OR 2 values together and return the answer

Ex: `bitwise_or(10, 2)` -> `10`

INPUTS: `x` (numeric), `y` (numeric) Two numbers

OUTPUT: Outputs the result of bitwise OR operation on the input numbers

bitwise_xor(x, y)

Bitwise XOR 2 values together and return the answer

Ex: `bitwise_xor(10, 2)` -> `8`

INPUTS: `x` (numeric), `y` (numeric) Two numbers

OUTPUT: Outputs the result of bitwise XOR operation on the input numbers

ceil(x)

Round a decimal up to its integer equivalent.

Examples: Find the ceil of 2.6: `ceil(2.6)` -> `3`

INPUTS: `x` (numeric) A decimal number

OUTPUT: Outputs the smallest integer greater than or equal to x

cos(x)

Calculates the cosine of the supplied value in radians.

Examples: Find the cos of 2: `cos(2)` -> `-0.416146836547142294`

INPUTS: `x` (numeric) A number in radians

OUTPUT: Outputs the cosine of the input number

Examples: Find the radians equivalent of 180 degrees: `deg2rad(180)`-> `3.141592653589793`

INPUTS: `x` (numeric) A number in degrees

OUTPUT: Outputs the radians equivalent of the input number in degrees

divide(x,y)

Divides two numbers and returns the result

Ex: `divide(10,2)` -> `5`

INPUTS: `x` (numeric), `y` (numeric) The numbers to be divided

OUTPUT: Outputs the result of x divided by y

exp(x)

Returns the value of the constant e raised to the power of x

Ex: `exp(2)` -> `7.38905609893065`

INPUTS: `x` (numeric) The exponent to raise e to

OUTPUT: Outputs the result of e raised to the power of x

floor(x)

Rounds a decimal down to its nearest integer

Ex: `floor(2.6)` -> `2`

INPUTS: `x` (numeric) The decimal number to be rounded

OUTPUT: Outputs the nearest integer that is less than or equal to x

min

Returns the minimum of two values

max

Returns the maximum of two values

modulus(x, y)

Returns the remainder of dividing x by y.

Ex: `modulus(7,3)` -> `1`

INPUTS: `x` (numeric), `y` (numeric) two numbers

OUTPUT: Outputs the remainder of x divided by y

multiply(x, y)

Multiply 2 values together and return the answer.

Ex: `multiply(2,3)` -> `6`

INPUTS: `x` (numeric), `y` (numeric) two numbers

OUTPUT: Outputs the product of the 2 input values

number_format(x, decimals, decimalpoint, separator)

Format a number with flexible support over decimal places, thousands separator, and decimal separator.

Ex: `number_format(123456789, 2, ".", ",")` -> `"123,456,789.12"`

INPUTS: `x` (numeric) A single number to be formatted, `decimals` (numeric) Number of decimal points, `decimalpoint` (string) Decimal point separator, `separator` (string) Thousands separator

OUTPUT: Outputs the formatted number

pow(x, exp)

Returns the value raised to the power of exp.

Ex: `pow(2,3)` -> `8`

INPUTS: `x` (numeric) A single number, the base `exp` (numeric) A single number, the exponent

OUTPUT: Outputs the base raised to the power of the exponent

Ex: `rad2deg(pi)` -> `180`

INPUTS: `x`(numeric) A single number in radians

OUTPUT: Outputs the input value converted to degrees

round(x, precision)

Round a decimal with optional precision.

Ex: `round(3.14159265,3)` -> `3.142`

INPUTS: `x`(numeric) A single number to be rounded precision (numeric) Number of decimal places to round to

OUTPUT: Outputs the input value rounded to the specified number of decimal places

sin(x)

Calculates the sine of the supplied value in radians.

Ex: `sin(pi/2)` -> `1`

INPUTS: `x`sqrt(x) Returns the square root of the value

Examples: Find the square root of 9: sqrt(9) OUTPUT: 3

INPUTS: x (numeric) A single number

OUTPUT: Outputs the square root of the input value (numeric) A single number in radians

OUTPUT: Outputs the sine of the input value

sqrt(x)

Returns the square root of the value

Ex: `sqrt(9)` ->`3`

INPUTS: `x` (numeric) A single number

OUTPUT: Outputs the square root of the input value

subtract(x, y)

Subtract 2 values together and return the answer.

Ex: `subtract(10,5)` -> `5`

INPUTS: `x` (numeric), `y`(numeric) Two numbers

OUTPUT: Outputs the result of subtracting y from x

tan(x)

Calculates the tangent of the supplied value in radians.

Ex: `tan(pi/4)` -> `1`

INPUTS: `x` (numeric) A single number in radians

OUTPUT: Outputs the tangent of the input value

### Special Array Math Filters:

array_max

Finds the max value among the values of the array.

Ex: `max[2,5,3]` -> `5`

INPUTS: `array[x1, x2,...]` (array) an array of numbers to compare

OUTPUT: Outputs the largest number among the array.

array_min

Finds the minimum value among the values of the array.

Ex: `min[2,5,3]` -> `2`

INPUTS: `array[x1, x2,...]` (array) an array of numbers to compare

OUTPUT: Outputs the smallest number among the array.

Product

Returns the product of the values of the array.

Ex: `product[2,5,3]` -> `30`

INPUTS: `array[x1, x2,...]` (array) an array of numbers

OUTPUT: Outputs the product of the values of the array.

Sum

Returns the sum of the values of the array.

Ex: `sum[2,5,3]` -> 10

INPUTS: `array[x1, x2,...]` (array) an array of numbers

OUTPUT: Outputs the sum of the values of the array.

Last updated