HP 3000 Manuals

REM Function [ HP COBOL II/XL Reference Manual ] MPE/iX 5.0 Documentation


HP COBOL II/XL Reference Manual

REM Function 

The REM function returns a numeric value that is the remainder of
parameter-1 divided by parameter-2.  The function type is numeric.

Syntax 

     FUNCTION REM (parameter-1 parameter-2)

Parameters 

parameter-1           Must be class numeric.

parameter-2           Must be class numeric; must not be zero.

Return Value 

The returned value is the remainder of parameter-1 / parameter-2.  The
value is defined as the following expression:

     parameter-1 - (parameter-2 * FUNCTION INTEGER-PART (parameter-1 /
parameter-2))

The following table illustrates expected results for some values of
parameter-1 and parameter-2.

Parameter-1  Parameter-2     Result 

     13           6           +1.0

   13.55          -6         +1.55

    -13           6           -1.0

   -13.55         -6         -1.55

Example 

     01  NUM-REM     PIC 99 VALUE 0.
          :
     COMPUTE NUM-REM = FUNCTION REM (17 3).
     DISPLAY NUM-REM.

The above example displays the following:

     02



MPE/iX 5.0 Documentation