HP 3000 Manuals

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


HP COBOL II/XL Reference Manual

INTEGER Function 

The INTEGER function returns the greatest integer value that is less than
or equal to the argument.  The function type is integer.

Syntax 

     FUNCTION INTEGER (parameter-1)

Parameters 

parameter-1           Must be class numeric.

Return Value 

The returned value is the greatest integer less than or equal to the
value of parameter-1.  For example, if the value of parameter-1 is -1.5,
a value of -2 is returned.  If the value of parameter-1 is +1.5, the
value of +1 is returned.

Example 

     77  NUM-FRACT    PIC S99V99 VALUE 12.94.
     77  NUM-INT      PIC S99V99 VALUE ZERO.
     77  NUM-NEG      PIC S99V99 VALUE -12.94.
           :
     COMPUTE NUM-INT = FUNCTION INTEGER (NUM-FRACT).
     DISPLAY NUM-FRACT.
     DISPLAY NUM-INT.

     COMPUTE NUM-INT = FUNCTION INTEGER (NUM-NEG).
     DISPLAY NUM-NEG.
     DISPLAY NUM-INT.

The above example displays the following:

     +12.94
     +12.00
     -12.94
     -13.00



MPE/iX 5.0 Documentation