COBOL Manual for TNS and TNS/R Programs

Intrinsic Functions
HP COBOL Manual for TNS and TNS/R Programs522555-006
14-55
SQRT Function
SQRT Function
SQRT, a numeric function, returns a value that approximates the square root of its
argument.
argument
is a numeric argument whose value is zero or positive.
The returned value is approximately:
Note. This function requires the CRE. To use this function in a TNS HP COBOL program,
compile the program with the directive ENV COMMON.
Example 14-38. SQRT Function
Code:
DATA DIVISION.
WORKING-STORAGE SECTION.
01 A PICTURE S9V99.
PROCEDURE DIVISION.
MOVE FUNCTION SQRT (0) TO A.
DISPLAY A.
MOVE FUNCTION SQRT (25) TO A.
DISPLAY A.
MOVE FUNCTION SQRT (100) TO A.
DISPLAY A.
MOVE FUNCTION SQRT (47) TO A.
DISPLAY A.
MOVE FUNCTION SQRT (7.923) TO A.
DISPLAY A.
Output:
00.000
05.000
10.000
06.855
02.814
( )
SQRTFUNCTION argument
VST461.vsd
argument