Introduction to Intrinsic Functions

Intrinsic functions are subprograms that are built into the ACUCOBOL-GT library. They save time by simplifying common tasks that your COBOL programs might need to perform. For example, intrinsic functions can perform statistical calculations, convert strings from upper to lower case, compute annuities, derive values for trigonometric functions such as sine and cosine, and perform general utility tasks such as determining the compile date of the current object file.

Intrinsic functions are sometimes called built-in or library functions.

To access an intrinsic function, you include it inside a COBOL statement (typically a MOVE or COMPUTE statement). Here's an example of a statement that uses the min intrinsic function:

move function min(3,8,9,7) to my-minimum. 

This COBOL statement can be translated into: move the result derived from performing the min function on the literals "3, 8, 9, and 7" to the variable my-minimum.

Note the presence of the required word function, followed by the name of the function (min) and then its parameters. This required word can be replaced by a $ sign, as shown in the following example.

Each intrinsic function is evaluated to a data value. This value is stored in a temporary storage area that you cannot access directly in your program. The only way to get the derived value of an intrinsic function is to provide the name of a data item into which the resulting value should be placed. In the example shown above, the variable my-minimum receives the derived value of the min function.

In the example above, the parameters passed to the min function are literals. It is also permissible to pass data items, as shown here:

compute my-sine = $sin(angle-a).
Note: When the return value of a function is a double, the precision of the return value is limited to that supported by the underlying hardware.

However, if your COBOL program is compiled for 31-digit support (-Dd31), numeric functions are computed using special floating point arithmetic that is accurate to approximately 33 digits, regardless of the floating-point representation on the host machine.

The functions that return a double include: ABS, ABSOLUTE-VALUE, ACOS, ANNUITY, ASIN, ATAN, COS, LOG, LOG10, MEAN, MEDIAN, MIDRANGE, NUMVAL, NUMVAL-C, PRESENT-VALUE, RANDOM, REM, SIN, SQRT, STANDARD-DEVIATION, TAN, and VARIANCE.