COMTRAN Reconstruction

F28-8043 · June 1960

Page 44

PDF page 50 of 124. Download the scanned PDF

The page as scanned

The scan of PDF page 50 of F28-8043
Select the scan to open it at full size.

The text read off it

[page 44]

Arithmetic Commands

Two of the verbs in the Commercial Translator vocabulary are used for arithmetic. They are SET and ADD. These two verbs form the basis for the three types of arithmetic commands, as follows:

The SET Command

The SET command permits the programmer to specify a computation or a sequence of computations. It can be used for all arithmetic. The general form of this command is:

SET variable.1, variable.2, ... variable.n = arithmetic expression

The equal sign in the SET command is used in the sense of replacement. It means, "replace the value of the variable(s) on the left side of the equal sign with the value of the expression on the right." If required, the result of a computation will be edited automatically according to the format of a receiving field as specified in the data description. For example, if a result represents an amount of money, editing appropriate to the defined format of the money field will be performed.

Ordinarily the result of the SET operation will be rounded to the number of places indicated by the format description of the result field or fields. If the dropping of digits (instead of rounding) is desired, the arithmetic expression is followed by

... TRUNCATED

In the process of storing the final result of a SET command it is possible for a loss of significant high-order digits to occur. For example, if a result field has been defined as having three places to the left of the decimal point and a result such as 1001 is developed, the high-order "1" will be lost. This situation is known as "overflow." If the SET command specifies just one result field (i.e., if it has only one variable-name to the left of the equal sign), the programmer may anticipate and provide for an overflow by appending

..., ON OVERFLOW any imperative clause

at the end of the SET command. In the event of an overflow, the object program will execute the command thus specified instead of storing the erroneous result.

Some examples of the SET command are:

SET GROSS.PAY = BASE.RATE * 40.
SET NET.PAY = GROSS.PAY − (FICA + STATE.TAX +
    DEDUCTIONS).
SET A= B * (C + D), ON OVERFLOW GO TO ERROR.
SET REORDER = ORDER.AMT * TR (STOCK.LEVEL LT
    ORDER.POINT).
SET APPROX = 2 * SQUARE.ROOT ((X)) TRUNCATED.
SET A, B, C =D.