🛠️ P3/COBOL 25.1.0-SNAPSHOT is available for preview.
Reference Manual
Intrinsic Functions

Summary of Intrinsic Functions

This summarizes the intrinsic functions that are available in P3/COBOL. It is essentially a superset of the 1985 standard functions incorporating additional functions available on other common COBOL dialects and some unique to this COBOL. Many of the additional functions are compiled by P3/COBOL for syntax checking purposes in the editor, but are not currently implemented.

The implementation markers in this table follow the compiler's intrinsic-function registry. A function marked with footnote 1 is recognized for syntax checking but is not implemented by the runtime. Functions without that marker are implemented.

For background on national argument and result types, conversion between DISPLAY and national data, and national collating sequences, see National Data in P3/COBOL.

The Arguments column defines argument type and the Type column defines the type of the function, as follows:

ArgumentType
Alphmeans alphabetic
Anummeans alphanumeric Bool means boolean
Indmeans index
Intmeans integer
Keymeans a keyword
Natmeans national
Nummeans numeric
Ordmeans an ordering table
Ptrmeans pointer
Typemeans a type declaration
Arg or Argsmeans the type of the argument or arguments, respectively

Num in the arguments column includes Int. Both Int and Num are listed in the arguments column when the type of the argument determines the type of the function.

Anum in the arguments column includes strongly-typed group items. When the type of the argument determines the type of the function, the function is an alphanumeric function when any of the arguments is strongly-typed, even when all the arguments of the function are of the same type.

In the Arguments column, the following conventions apply:

  1. A digit immediately following the argument type indicates the argument's position in the list of arguments.
  2. If more than one argument type may appear in a given position, they are separated by the word 'or'.
  3. If an argument in a given position in the list may consist of more than one component, the components are separated by the word 'and'.
  4. Commas are used only to separate an argument from the next argument in the argument list.
💡

For example, the sequence 'Alph1 or Anum1 or Nat1, Alph2 or Anum2 or Nat2 or Key2 or Key2 and Loc2, Key3' in the 'Arguments' column is to be interpreted as follows:

  1. The first argument is alphabetic, alphanumeric, or national.
  2. The second argument is alphabetic, alphanumeric, national, a keyword alone, or a keyword with a locale specification.
  3. The third argument is a keyword.

The 'Value returned' column gives a synopsis of the value returned; additional details are specified in the definition of the function.

NameArgument(s)TypeValue returned
ABBREVIATEAnum1 or Nat1ArgThe abbreviated value of argument-1
ABSInt1 or Num1ArgThe absolute value of argument-1
ACOSNum1NumArccosine of argument-1
ADDRAlph1 ... or
Anum1 ... or
Ind1 ... or
Int1 ... or
Nat1 ... or
Num1 ...
PtrAddress of the argument-1 (as a P3/COBOL pointer)
ANNUITYNum1, Int2NumRatio of annuity paid for argument-2 periods at interest of argument-1 to initial investment of one
ATANNum1NumArctangent of argument-1
ASINNum1NumArcsine of argument-1
BOOLEAN-OF-INTEGER1Int1, Int2BoolA boolean item representing the binary value equivalent of the numeric value in argument-1
BYTE-LENGTHAnyIntLength of argument-1 in number of bytes
CHARInt1AnumCharacter in position argument-1 of the alphanumeric program collating sequence
CHAR-NATIONALInt1NatCharacter in position argument-1 of the national program collating sequence
COMBINED-DATETIMEInt1, Num2NumNumeric representation of combined integer date and standard numeric time
COSNum1NumCosine of argument-1
CURRENT-DATEAnumCurrent date and time and local time differential
DATE-OF-INTEGERInt1IntStandard date equivalent (YYYYMMDD) of integer date in argument-1
DATE-TO-YYYYMMDDInt1, Int2, Int3IntArgument-1 converted from YYMMDD to YYYYMMDD based on the values of argument-2 and argument-3
DATEVAL12Int1 or Anum1ArgThe date value of argument-1
DAY-OF-INTEGERInt1IntJulian date equivalent (YYYYDDD) of integer date in argument-1
DAY-TO-YYYYDDDInt1, Int2, Int3IntArgument-1 converted from YYDDD to YYYYDDD based on the values of argument-2 and argument-3
DISPLAY-OFNat1, Alph2 or Anum2AnumUsage display representation of argument argument-1. Argument-2, if specified, is an alphanumeric character to be used when no alphanumeric character corresponds to a national character in argument-1
ENumThe value of e, the natural base
ESCAPE-PATTERNAnum1 or Nat1NatEscapes argument-1 string for use as regular expression matching the argument-1 string
EXCEPTION-FILEAnumInformation about the file exception that raised an exception
EXCEPTION-FILE-NNatInformation about the file exception that raised an exception
EXCEPTION-LOCATION1AnumImplementor-defined location of exception
EXCEPTION-LOCATION-N1NatImplementor-defined location of exception
EXCEPTION-STATEMENT1AnumName of statement causing an exception
EXCEPTION-STATUS1AnumException-name identifying last exception
EXPNum1Nume raised to the power argument-1
EXP10Num1Num10 raised to the power argument-1
FACTORIALInt1IntFactorial of argument-1
FORMATTED-CURRENT-DATEAnum1 or Nat1ArgFormatted date equivalent of current date and time in the format specified in argument-1
FORMATTED-DATEAnum1 or Nat1, Int2ArgFormatted date equivalent of integer date contained in argument-2 in the format specified in argument-1
FORMATTED-DATETIMEAnum1 or Nat1, Int2, Num3, Int4ArgFormatted date (from integer date in argument-2) and time (from standard numeric time in argument-3) in the format specified by argument-1. Offset from UTC, if the format Int4 requires it, is supplied by argument-4
FORMATTED-TIMEAnum1 or Nat1, Num2, Int3ArgFormatted time equivalent of standard numeric time contained in argument-2 in the format specified in argument-1. Offset from UTC, if the format requires it, is supplied by argument-3
FRACTION-PARTNum1NumFraction part of argument-1
HEX-OFAnum1 or Nat1NatString represention of argument-1 as hexadecimal digits
HIGHEST-ALGEBRAIC1Anum1 or Int1 or Nat1 or Num1Int NumGreatest algebraic value that may be represented in argument-1
INTEGERNum1IntThe greatest integer not greater than argument-1
INTEGER-OF-BOOLEAN1Bool1IntThe numeric value of a BINARY-DOUBLE item whose bit configuration is the same as argument-1, right-justified
INTEGER-OF-DATEInt1IntInteger date equivalent of standard date (YYYYMMDD) in argument-1
INTEGER-OF-DAYInt1IntInteger date equivalent of Julian date (YYYYDDD) in argument-1
INTEGER-OF-FORMATTED-DATEAnum1 or Nat1, Anum2 or Nat2IntInteger date equivalent of date contained in argument-2 whose format is described by argument-1
INTEGER-PARTNum1IntInteger part of argument-1
LENGTHAlph1 or Anum1 or Bool1 or Ind1 or Nat1 or Num1 or Type1IntLength of argument-1 in number of character positions or number of boolean positions
LOCALE-COMPARE1Alph1, Anum1 or Nat1, Alph2, Anum2 or Nat2, Loc3AnumA character indicating the result of comparing argument-1 to argument-2 using an ordering defined by a locale specified by argument-3
LOCALE-DATE1Anum1 or Nat1, Loc2AnumA character string containing a date specified by argument-1 in a format specified by argument-2 and a locale
LOCALE-TIME1Anum1 or Nat1, Loc2AnumA character string containing a time specified by argument-1 in a format specified by a locale
LOCALE-TIME-FROM-SECONDS1Num1, Loc2AnumA character-string containing a time specified by argument-1, in a format specified by a locale specified by argument-2
LOGNum1NumNatural logarithm of argument-1
LOG10Num1NumLogarithm to base 10 of argument-1
LOWER-CASEAlph1 or Anum1 or Nat1ArgA character string with any uppercase letters in argument-1 set to lowercase
LOWEST-ALGEBRAIC1Anum1 or Int1 or Nat1 or Num1Int NumLowest algebraic value that may be represented in argument-1
MAXAlph1 ... or
Anum1 ... or
Ind1 ... or
Int1 .... or
Nat1 ... or
Num1 ...
ArgsValue of maximum argument
MEANNum1 ...NumArithmetic mean of arguments
MEDIANNum1 ...NumMediaMean of minimum and maximum arguments
MINAlph1 ... or
Anum1 ... or
Ind1 ... or
Int1 ... or
Nat1 ... or
Num1 ...
ArgsValue of minimum argument
MODInt1, Int2Intargument-1 modulo argument-2
NATIONAL-OFAlph1 or Anum1, Nat2NatUsage national representation of argument-1. Argument-2, if specified, is a national character to be used when no national character corresponds to an alphanumeric character in argument-1
NUMVALAnum1 or Nat1NumNumeric value of simple numeric string contained in argument-1
NUMVAL-CAnum1 or Nat1, Anum2 or Nat2 or Key2 and Loc2, Key3NumNumeric value of numeric string with optional currency sign and commas contained in argument-1. If specified, argument-2 is either a specified currency sign or a locale specification, and argument-3 specifies case insensitivity
NUMVAL-FAnum1 or Nat1NumNumeric value of numeric string representing a floating-point number contained in argument-1
ORDAlph1 or Anum1 or Nat1IntOrdinal position of argument-1 in collating sequence
ORD-MAXAlph1 ... or
Anum1 ... or
Ind1 .... or
Nat1 ... or
Num1 ...
IntOrdinal position of maximum argument
ORD-MINAlph1 ... or
Anum1 ... or
Ind1 ... or
Nat1 ... or
Num1 ...
IntOrdinal position of minimum argument
PINumThe value of π
PRESENT-VALUENum1, Num2 ...NumPresent value of a series of future period-end amounts, argument-2, at a discount rate of argument-1
RANDOMInt1NumRandom number; optional argument-1 specifies seed value
RANGEInt1 ... or
Num1 ...
ArgValue of maximum argument minus value of minimum argument
REMNum1, Num2NumRemainder of division of argument-1 by argument-2
REVERSEAlph1 or Anum1 or Nat1ArgReverse order of the characters of argument-1
SECONDS-FROM-FORMATTED-TIMEAnum1 or Nat1,NumStandard numeric time equivalent of the data contained in argument-2 as described by the format specified in argument-1
SECONDS-PAST- MIDNIGHTNumSeconds past midnight as provided by the system
SIGNNum1IntThe sign of argument-1
SINNum1NumSine of argument-1
SQRTNum1NumSquare root of argument-1
STANDARD-COMPARE1Alph1 or Anum1 or Nat1, Alph2 or Anum2 or Nat2, Ord3, Int4AnumA character indicating the result of comparing argument-1 to argument-2 using the ordering specified by argument-3 at the comparison level specified by argument-4
STANDARD-DEVIATIONNum1 ...NumStandard deviation of arguments
SUMInt1 ... orArgsSum of arguments
TANNum1NumTangent of argument-1
TEST-DATE-YYYYMMDD1Int1Int0 if argument-1 is a valid standard date; otherwise identifies the sub-field in error
TEST-DAY-YYYYDDD1Int1Int0 if argument-1 is a valid Julian date; otherwise identifies the sub-field in error
TEST-FORMATTED-DATETIME1Anum1 or Nat1,
Anum2 or Nat2
Int0 if argument-2 conforms in form to the format specified error in argument-1 and represents a valid date, time or combined representation according to that description; otherwise, identifies the character in
TEST-NUMVALAnum1 or Nat1Int0 if argument-1 conforms to the requirements of the NUMVAL function; otherwise identifies the character in error
TEST-NUMVAL-CAnum1 or Nat1, Alph2 or Anum2 or Nat2 or Key2 or Key2 and Loc2, Key3Int0 if argument-1 conforms to the requirements of the NUMVAL-C function; otherwise, identifies the character position in error. Argument-2 specifies either a currencysign or a locale specification, and argument-3 specifies case insensitivity
TEST-NUMVAL-F1Anum1 or Nat1Int0 if argument-1 conforms to the requirements of the NUMVAL-F function; otherwise identifies the character in
TIME-MILLIIntThe time in milliseconds since the beginning of epoch
TIME-NANOIntThe time in nanoseconds since the beginning of epoch
TRIMAlph1 or Anum1 or Nat1, Key2ArgsThe value of argument-1 with leading spaces, trailing spaces, or both, deleted.
UNDATE12Int1 or Anum1ArgThe non-date value of a date-type argument-1
UPPER-CASEAlph1 or Anum1 or Nat1ArgA character string with any lowercase letters in argument-1 set to uppercase
VARIANCENum1 ...NumVariance of argument-1
WHEN-COMPILEDAnumDate and time compilation unit was compiled
YEAR-TO-YYYYInt1, Int2, Int3IntArgument-1 converted from YY to YYYY based on the values of argument-2 and argument-3 a A function that has only alphabetic arguments is type alphanumeric.
YEARWINDOW12IntStarting year number of the current century window

1 This function is recognized for syntax checking, but is not implemented by the runtime at this time.


2 The function definition follows IBM COBOL for z/OS with the NODATEPROC option in effect.