# Formulas

- Numbers - Constants - Variables/PV Names - Basic Computations - Boolean Operations - Functions -

The Data Browser, the Alarm Server 'filter' and maybe other CSS tools support the following type of formula.

## Numbers

Numbers can be entered as

- 3
- -3.14
- -2.123e-14

## Constants

Predefined constants

- E
- PI

## Variables/PV Names

In the Data Browser, formulas can contain variables which are mapped to other Data Browser traces. In the Alarm Server 'filter', formulas can contain PV names. In either case, enclose names that contain numbers or other special characters with single quotes:

- PlainName
- 'Name-with:special/characters'
- '4aNameThatStartsWithANumber'

## Basic Computations

Basic computations are supported with the standard order of operations:

- -3.14 + 2 - 1.10
- -12/-3
- 1 + 2 * 3 - 4
- (1 + 2) * (3 - 4)
- -(3.14)
- -(-3.14)

## Boolean Operations

Boolean operations result in 0.0 or 1.0 for 'false' respectively 'true', supporting the following operators for comparisons, 'not', 'or', 'and', as well as the C/Java type if-then-else operator:

- 2 == 2
- 2 != 3
- 2 < 3
- 3 > 2
- 2 ≤= 3
- 3 >= 2
- ! (2 == 3)
- (1 == 2) | (2 == 2)
- (1 == 1) & (2 == 2)
- (2 < 3) ? (1.0) : (0.0)

## Functions

Random number [0 ... x[:

- rnd(x)

The following functions take one or two arguments as indicated and return the value defined by the respective Java 'Math' routine:

- abs(a)
- acos(a)
- asin(a)
- atan(a)
- ceil(a)
- cos(a)
- cosh(a)
- exp(a)
- expm1(a)
- floor(a)
- log(a)
- log10(a)
- round(a)
- sin(a)
- sinh(a)
- sqrt(a)
- tan(a)
- tanh(a)
- toDegrees(a)
- toRadians(a)
- atan2(a, b)
- hypot(a, b)
- pow(a, b)

These special functions take two or more arguments:

- min(a, b, c, d, e)
- max(a, b, c, d, e)