HP 3000 Manuals

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


HP COBOL II/XL Reference Manual

INTEGER-PART Function 

The INTEGER-PART function returns an integer that is the integer portion
of parameter-1 (parameter-1 is truncated).  The function type is integer.

Syntax 

     FUNCTION INTEGER-PART (parameter-1)

Parameters 

parameter-1           Must be class numeric.

Return Value 

One of the following, depending on the value of parameter-1:

     parameter-1    Return Value                                                                                                     

        0           0

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

     Negative       The least integer greater than or equal to the value
                    of parameter-1.  For example, if the value of
                    parameter-1 is -1.5, the value -1 is returned.

Example 

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

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

The above example displays the following:

     +12.94
     +12.00
     -12.94
     -12.00



MPE/iX 5.0 Documentation