Previous Topic: Overview of Arithmetic OperationsNext Topic: Overview of Conditional Operations


Arithmetic Operations

Purpose

Perform addition, multiplication, subtraction, and division.

Syntax

►►─┬───────────┬──┬────────────┬─ value result-field-name ────────────────────►◄
   └─ Compute ─┘  ├─ ROUND ────┤
                  └─ TRUNCate ─┘

Syntax Rules

Compute

Identifies a compound arithmetic operation; it is an optional keyword for simple arithmetic operations unless either parentheses enclose the arithmetic operation or the ROUND/TRUNCATE clause is specified.

ROUND

Rounds the resulting value to the number of decimal positions defined for the result field. CA Culprit rounds up if the value is .5 or greater; for example, 0.5 is rounded to 1.

TRUNCate

Truncates the resulting value to the number of decimal positions defined for the result field.

If one of these options is specified, it must follow the keyword COMPUTE.

ROUND is the default when PROFILE option RELEASE=6 is in effect; TRUNCATE is the default when PROFILE option RELEASE=5 is in effect.

value

Specifies an arithmetic operation that contains operands and operators, as follows:

Operator

Synonym

Meaning

+

ADD

Indicates that the value of the left operand is added to the value of the right operand.

-

S or MINUS

Indicates that the value of the right operand is subtracted from the value of the left operand.

X

TIMES

Indicates that the value of the left operand is multiplied by the value of the right operand.

/

DIVIDE

Indicates that the value of the left operand is divided by the value of the right operand. If the value of the right operand is zero, a divide exception occurs and the result of the operation is set to zero.

Nonnumeric data and arithmetic overflows cause error messages. Arithmetic overflows are reported by the extended error-handling facility.

Note: For more information, refer to the CA Culprit for CA IDMS Messages and Codes Guide.

result-field-name

The name of a numeric work field that receives the result of the arithmetic operation. Result-field-name must be defined on a work field parameter.

More information:

Release 5 and 6 Default Actions

PROFILE Parameter