Intrinsic functions - Enterprise COBOL for z/OS 6.3.0
You can use numeric intrinsic functions only in places where numeric expressions are allowed.
These functions can save you time because you don't have to code the many common types of calculations that they provide.
Numeric intrinsic functions return a signed numeric value, and are treated as temporary numeric data items.
Numeric functions are classified into the following categories:
- Integer
- Those that return an integer
- Floating point
- Those that return a long (64-bit) or extended-precision (128-bit) floating-point value (depending on whether you compile using the default option ARITH(COMPAT)
or using ARITH(EXTEND))
- Mixed
- Those that return an integer, a floating-point value, or a fixed-point number with decimal places, depending on the arguments
You can use intrinsic functions to perform several different arithmetic operations, as outlined in the following table.
Table 1. Numeric intrinsic functions
| Number handling |
Date and time |
Finance |
Mathematics |
Statistics |
LENGTH MAX MIN NUMVAL NUMVAL-C NUMVAL-F SIGN TEST-NUMVAL TEST-NUMVAL-C TEST-NUMVAL-F ORD-MAX
ORD-MIN
|
CURRENT-DATE DATE-OF-INTEGER DATE-TO-YYYYMMDD DAY-OF-INTEGER DAY-TO-YYYYDDD INTEGER-OF-DATE INTEGER-OF-DAY
WHEN-COMPILED YEAR-TO-YYYY
|
ANNUITY PRESENT-VALUE
|
ABS ACOS ASIN ATAN COS E EXP EXP10 FACTORIAL INTEGER INTEGER-PART LOG LOG10 MOD
PI REM SIN SQRT SUM TAN
|
MEAN MEDIAN MIDRANGE RANDOM RANGE STANDARD-DEVIATION VARIANCE
|
Examples: numeric intrinsic functions
You can reference one function as the argument of another.
A nested function is evaluated independently of the outer function (except when the compiler determines whether a mixed function should be evaluated using
fixed-point or floating-point instructions).
You can also nest an arithmetic expression as an argument to a numeric function.
For example, in the statement below, there are three function arguments (a, b, and the arithmetic expression (c / d)):
COMPUTE X = FUNCTION SUM(A B (C / D))
You can reference all the elements of a table (or array) as function arguments by using the ALL subscript.
You can also use the integer special registers as arguments wherever integer arguments are allowed.
Many of the capabilities of numeric intrinsic functions are also provided by Language Environment® callable services.
Published: 2020-12-14
© Copyright IBM Corp.