Crystal Reports  

Arithmetic Operators (Crystal Syntax)

Arithmetic operators are used to combine numbers, numeric variables, numeric fields and numeric functions to get another number.

The arithmetic operators are addition (+), subtraction (-), multiplication (*), division (/), integer division (\), percent (%), modulus (Mod), negation (-) and exponentiation (^).

Examples

//Outstanding preferred stock as a percent of
//common stock
{Financials.Preferred Stock} %
{Financials.Common Stock};
//The square root of 9, Sqr(9) is 3
//The formula returns 17
7 + 2 * 3 - 2 + Sqr(6 + 3) * Length("up");

Order of Precedence

In general, the program evaluates expressions in the following order:

List of arithmetic operators, from highest precedence to lowest

Example

Multiplication and division are performed first from left to right. Then addition and subtraction are performed. For example, 5 + 10 * 3 = 5 + 30 = 35.

You can change this order of precedence by using parentheses. For example, (5 + 10) * 3 = 15 * 3 = 45. If you are unsure of the order of precedence, it is a good idea to clarify your intentions with parentheses.

See Also

Operators | Performing Report Calculations