Arithmetic Expressions

  

DEVELOPER

The evaluation of an arithmetic expression results in a numeric value.  An arithmetic expression can be any of the following:

 

Example

COUNTER - 1

This expression consists of a variable name, the subtraction operator (-), and a constant.

It equals the value of COUNTER minus 1.

 

Valid arithmetic operators are listed in the following table:   

Symbol
 

Purpose

+
 

Addition

-
 

Subtraction

*
 

Multiplication

/
 

Division

**
 

Exponential

 

When evaluating expressions that contain more than one operator, PROIV follows precedence rules to determine the order in which operations are performed.  An operation with higher precedence is evaluated before an operation with lower precedence.

Operator
 

Precedence

**
 

Highest

*  /
 

 

+  -
 

Lowest

 

Parentheses can be used to alter the normal precedence.

 

Two operations of the same precedence, such as * and /, are evaluated from left to right.  Examples:
 

A * B + C / D

The multiplication (*) and division (/) operations are
performed before the addition.

A + B * C

B is multiplied by C, then A is added to the result.

(A + B) * C

A is added to B, then the result is multiplied by C.

 

Comment on this topic

Topic ID: 520005