HP 3000 Manuals

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


HP COBOL II/XL Reference Manual

SQRT Function 

The SQRT function returns a numeric value that is the square root of
parameter-1.  The function type is numeric.

Syntax 

     FUNCTION SQRT (parameter-1)

Parameters 

parameter-1           Must be class numeric; the value must be zero or
                      positive.

Return Value 

The returned value is the absolute value of the approximation of the
square root of parameter-1.

Example 

     01  A-NUMBER        PIC 99      VALUE 35.
     01  NUM-SQ-ROOT     PIC 999V999 VALUE ZERO.
          :
     COMPUTE NUM-SQ-ROOT = FUNCTION SQRT (81).
     DISPLAY NUM-SQ-ROOT.
     COMPUTE NUM-SQ-ROOT = FUNCTION SQRT (A-NUMBER).
     DISPLAY NUM-SQ-ROOT.

The above example displays the following:

     009.00
     005.916



MPE/iX 5.0 Documentation