Previous Topic: New Topic

Next Topic: Move

Modulo

The *MODULO built-in function specifies the remainder of a division of two fields. The *MODULO function provides more control over the remainder precision and is a single value field as opposed to the *DIV With Remainder, which returns two values. This allows this function to be used in *COMPUTE functions.

There are four parameters for this function type:

Note: The final result of the *MODULO operation depends greatly on the field domain defined for both the *Quotient definition field and the *Result field. For example, suppose you want to calculate the modulo for the following expression:

5.30 / 2.10 = 2.5238

The following table shows three different modulo values (*Result) for this operation due to the field length defined for the *Quotient definition field and the *Result field.

Length of *Quotient Definition Field

Length of *Result Field

Quotient

(Work Field VValue)

Modulo

(*Result value)

4.0

6.4

2

  1.1

4.2

6.4

2.52

   .0080

4.2

6.2

2.52

   .00

You can use the *MODULO built-in function as a sub-function to the *COMPUTE built-in function, thereby determining the remainder of a division operation within the compute expression.

CA 2E implements the *MODULO built-in function using similar code to *DIV (with remainder).

Example

This is an example of the *MODULO built-in function.

>USER: Process detail record .-- : WRK.MODULO Field = RCD.EXT Price\RCD.Quantity <<< ’--