# Custom expression for alarms

When adding an alarm in PicoLog 6, you can choose between three methods of defining an alarm condition: threshold, channel disconnection and custom expression editor.

A custom expression for alarms in PicoLog 6 requires a Boolean output (true or false), which you can define using any combination of a wide range of arithmetic, Boolean, relational, statistical and trigonometric operators and constants as listed below:

## Arithmetic functions  Brackets for defining operator precedence    standard arithmetic functions `x ^ y` : x raised to the power of y `e ^ x` : exponential function of x `x % y` : modulus (remainder of an integer division) of x divided by y n`!` : factorial of integer n `log(x [,base])` : logarithm of x to base 10 (or other base if specified). Alternatively use `log10(x)` : base-10 logarithm of x `log(x, e)` : natural logarithm of x `sqrt(x)` : square root of x `abs(x)` : absolute value of x `ceil(x)` : x rounded towards positive infinity `floor(x)` : x rounded towards negative infinity `round(x[, n])` : x rounded towards nearest integer (or to `n `decimal places if specified)

## Relational operators (used in alarms for comparing values)

`x == y` : test whether two values are equal

`x != y` : test whether two values are unequal `x < y` : if x is less than y `x > y `: if x is greater than y `x <= y `: if x is less than or equal to y `x >= y `: if x is greater than or equal to y

## Boolean operators `x and y` : Boolean AND of x and y `x or y` : Boolean OR of x and y `not x` : Boolean inverse of x `x xor y` : Boolean exclusive-OR of x and y

## Statistical functions `max(a, b, c...)` : maximum of all values in the list `min(a, b, c...)` : minimum of all values in the list `mean(a, b, c...)` : mean of all values in the list `median(a, b, c...)` : median of all values in the list

## Trigonometric functions `sin(x)` : sine of x `cos(x)` : cosine of x `tan(x)` : tangent of x

## Special functions

`operand1 ? operand2 : operand3`

The conditional operator (? :), also called the ternary operator. Example: `x > 0 ? x*4 : x*3`

The conditional operator works as follows:

• If `operand1 `evaluates to true, `operand2 `is evaluated
• If `operand1 `evaluates to false, `operand3 `is evaluated

`x == disconnected`

True if the data from channel x belongs to a disconnected device

## Constants pi: the ratio of a circle's circumference to its diameter (3.141592653589793)

## Scientific notation

`1.4e3` = 1400

`22e-3` = 0.022