PreviousProcedure Division Procedure Division - ACCEPT - DIVIDENext

Chapter 11: Procedure Division - Intrinsic Functions

The Intrinsic Function module allows you to reference a data item whose value is derived automatically at the time of reference during the execution of the object program.

If your program uses intrinsic functions, you will also require the floating-point module. See your COBOL system documentation about building and linking for details of run-time system support modules.

11.1 Function-name

A function is a temporary data item whose value is determined at the time the function is referenced during the execution of a statement. An intrinsic-function-name is a COBOL word that is one of a specified list of COBOL words which can be used in COBOL source programs. (See the section Definitions of Functions later in this chapter.)

11.2 Function Definition and Returned Value

The definition of each function specifies:

11.3 Function-identifier

A function-identifier is used by the programmer to reference a function in the Procedure Division of a COBOL source program. (See the section Function-Identifier in the chapter Concepts of the COBOL Language.)

11.4 Value Returned by a Function

The value returned by a function is considered to be a data value. A mechanism is provided at run time to assign a data value to a function when it is referenced. In order to determine the function's value, the evaluation mechanism requires access to data values provided by the referencing program. These data values are provided by specifying parameters, known as arguments, when referencing the function. Specific functions can place constraints on these arguments, such as range, and so on. If, at the time a function is referenced, the arguments specified for that reference do not have values that comply with the specified constraints, then the returned value for the function is undefined.

11.5 Arguments

Arguments specify values used in the evaluation of a function. Arguments are specified in the function-identifier. These arguments can be specified as identifiers, as arithmetic expressions, or as literals. The definition of a function specifies the number of arguments required, which can be zero, one, or more. For some functions, the number of arguments which can be specified is variable. The order in which arguments are specified in a function-identifier determines the interpretation given to each value in arriving at the function value. Arguments may be required to have a certain class or a subset of a certain class. The four types of argument are:

  1. Numeric. An arithmetic expression must be specified. The value of the arithmetic expression, including operational sign, is used in determining the value of the function.

  2. Alphabetic. An elementary data item of the class alphabetic or a nonnumeric literal containing only alphabetic characters must be specified. The size associated with the argument can be used in determining the value of the function.

  3. Alphanumeric. A data item of the class alphabetic or alphanumeric or a nonnumeric literal must be specified. The size associated with the argument can be used in determining the value of the function.

  4. National. An elementary data item of class national or a national literal must be specified. The size associated with the argument can be used in determining the value of the function.

  5. Integer. An arithmetic expression which will always result in an integer value must be specified. The value of the arithmetic expression, including operational sign, is used in determining the value of the function.

The rules for a function can place constraints on the permissible values for arguments, in order to accurately determine the function's value. If, at the time a function is referenced, the arguments specified for that reference do not have values within the permissible range, the returned value for the function is undefined.

When the definition of a function permits an argument to be repeated a variable number of times, a table can be referenced by specifying the data-name and any qualifiers that identify the table, followed immediately by subscripting where one or more of the subscripts is the word ALL.

When ALL is specified as a subscript, the effect is as if each table element associated with that subscript position were specified. The order of the implicit specification of each occurrence is from left to right, with the first (or leftmost) specification being the identifier with each subscript specified by the word ALL replaced by one, the next specification being the same identifier with the rightmost subscript specified by the word ALL incremented by one.

This process continues with the rightmost ALL subscript being incremented by one for each implicit specification until the rightmost ALL subscript has been incremented through its range of values. If any additional ALL subscripts exist, the subscript immediately to the left of the rightmost ALL subscript is incremented by one, the rightmost ALL subscript is reset to one and the process of varying the rightmost ALL subscript is repeated. The ALL subscript to the left of the rightmost ALL subscript is incremented through its range of values. For each additional ALL subscript this process is repeated in turn until the leftmost ALL subscript has been incremented by one through its range of values.

If the ALL subscript is associated with an OCCURS DEPENDING ON clause, the range of values is determined by the object of the OCCURS DEPENDING ON clause. The evaluation of an ALL subscript must result in at least one argument, otherwise the result of the reference to the function-identifier is undefined.

Example
 01 Test-Fields.
     10 OT-Elem                  PIC 9(02).
     10 Arr.
         15 Ind occurs 5 times        PIC 9(02).
     compute OT-Elem = function sum (IND(ALL)).

is equivalent to specifying

     compute OT-Elem = function sum (IND(1), IND(2), IND(3),
                                            IND(4), IND(5)).

The ALL subscript can also be used with a table that has a variable number of elements as in the following example:

 01 Test-Group.
     03 OT-Elem               pic 9(15) binary.
     03 table-length          pic s9(9) binary.
     03 array.
         05 Ind pic 9(2) occurs 1 to 200 times depending on
                              table length
      ...
     move 100 to table-length.
     compute OT-Elem = function sum (Ind(ALL))

These statements will sum the first 100 elements of the table. At the time the function is referenced, the number of elements specified by table-length determines that number of elements that are added.

11.6 Types of Functions

Data item functions are elementary data items and return alphanumeric,

national,

numeric or integer values. Data item functions are treated as elementary data items and cannot be receiving operands. The three types of data item functions are:

  1. Alphanumeric functions. These are of the class and category alphanumeric. The number of character positions in this data item is specified in the function definition. Alphanumeric functions have an implicit usage of DISPLAY.

  2. Numeric functions. These are of the class and category numeric. A numeric function is always considered to have an operational sign.

  3. Integer functions. These are of the class and category numeric. An integer function is always considered to have an operational sign.

  4. National Functions. These are of the class and category national. The number of character positions in this data item is specified in the function definition. National functions have an implicit usage of NATIONAL.

11.7 Date Conversion Functions

The Gregorian calendar is used in the date conversion functions. The starting date of Monday, January 1, 1601, was chosen to establish a simple relationship between the Standard Date and DAY-OF-WEEK; that is, the integer date 1 was a Monday, DAY-OF-WEEK 1.

For example, the statement:

compute DoW = 
     function rem (function integer-of-date (date-field) , 7)

returns the day of week for a given date, where 0 is Sunday, 1 is Monday, and so on.

11.8 Trigonometric Functions

Trigonometry deals with the relationships among the sides of a triangle and its angles. An angle can be measured in degrees, radians or Gon (grad). Since a computer usually generates trigonometric values by series approximation, the angle is specified in radians when used as the argument to the SIN, COS, and TAN functions or as the returned value from the ASIN, ACOS, and ATAN functions.

A radian is an arc of a circle whose length is equal to the circle's radius. Since the relationship between a circle's radius and circumference is C = 2 * P * r, and there are 360 degrees in a circle, we can derive from 360 = 2 * P * r, that the values for conversion are:

1 radian = 180/P = 57.295780 degrees
1 degree = P/180 = 0.01745329 radians.

Another scale that is sometimes used to measure angles is Gon, also known as grad. The values for conversion are:

1 radian = 200/P = 63.661977 Gon (grad)
1 Gon (grad) = P/200 = 0.01570796 radians.

11.9 Definitions of Functions

The following table summarizes the functions that are available.

The "a rguments" column defines argument type and the "type" column defines the type of the function, as follows:

Alph means alphabetic
Anum means alphanumeric
Int means integer
Nat means national
Num means numeric

Function-Name Arguments Type Value Returned
ABS Int1 or Num1 Depends upon arguments The absolute value of argument
ACOS Num1 Num Arcosine of Num1
ANNUITY Num1, Int2 Num Ratio of annuity paid for Int2 periods at interest of Num1 to initial investment of one
ASIN Num1 Num Arcsine of Num1
ATAN Num1 Num Arctangent of Num1
CHAR Int1 Anum Character in position Int1 of the alphanumeric program collating sequence
CHAR-NATIONAL Int1 Nat Character in position Int1 of the national program collating sequence
COS Num1 Num Cosine of Num1
CURRENT-DATE None Anum Current date and time and difference from Greenwich Mean Time
DATE-OF-INTEGER Int1 Int Standard date equivalent (YYYYMMDD) of integer date
DATE-TO-YYMMDD Int1 Int Argument-1 converted Int2 from YYMMDD to YYYYMMDD based on the value of argument-2
DAY-OF-INTEGER Int1 Int Julian date equivalent (YYYYDDD) of integer date
DAY-TO-YYYYDDD Int1 Int Argument-1 converted Int2 from YYDDD to YYYYDDD based on the value of argument-2
DISPLAY-OF Nat1, Anum1 Anum Usage display representation of argument Nat1
E None Num The value of e, the natural base
EXP Num1 Num e raised to the power Num1
EXP10 Num1 Num 10 raised to the power Num1
FACTORIAL Int1 Int Factorial of Int1
FRACTION-PART Num1 Num Fraction part of Num1
INTEGER Num1 Int The greatest integer not greater than Num1
INTEGER-OF-DATE Int1 Int The integer date equivalent of standard date (YYYYMMDD)
INTEGER-OF-DAY Int1 Int The integer date equivalent of Julian date (YYYYDDD)
INTEGER-PART Num1 Int Integer part of Num1
LENGTH Alph1 or Anum1 or
Nat1
or Num1
Int Length of argument in number of character positions
LENGTH-AN Alph1 or Anum1 or Int1 or Nat1 or Num1 Int Length of argument in number of alphanumeric character positions
LOG Num1 Num Natural logarithm of Num1
LOG10 Num1 Num Logarithm to base 10 of Num1
LOWER-CASE Alph1 or Anum1 or
Nat1
Depends upon argument All letters in the argument are set to lowercase
MAX Alph1 ... or Anum1 ... or Int1 ... or
Nat1 ... or
Num1 ...
Depends upon arguments* Value of maximum argument
MEAN Num1 ... Num Arithmetic mean of arguments
MEDIAN Num1 ... Num Median of arguments
MIDRANGE Num1 ... Num Mean of minimum and maximum arguments
MIN Alph1 ... or Anum1 ... or Int1 ... or
Nat1 ... or
Num1 ...
Depends upon arguments* Value of minimum argument
MOD Int1, Int2 Int Int1 modulo Int2
NATIONAL-OF Anum1,
Nat1
Nat Usage national representation of argument Anum1
NUMVAL Anum1 or
Nat1
Num Numeric value of simple numeric string
NUMVAL-C Anum1, Anum2, or
Nat1, Nat2
Num Numeric value of numeric string with optional commas and currency sign
ORD Alph1 or Anum1 or
Nat1
Int Ordinal position of the argument in collating sequence
ORD-MAX Alph1 ... or Anum1 ... or
Nat1 ... or
Num1
Int Ordinal position of maximum argument
ORD-MIN Alph1 ... or Anum1 ... or
Nat1 ... or
Num1
Int Ordinal position of minimum argument
PI None Num Value of
PRESENT-VALUE Num1 Num2 ... Num Present value of a series of future period-end amounts, Num2, at a discount rate of Num1
RANDOM Int1 Num Random number
RANGE Int1 ... or Num1 Depends upon arguments* Value of maximum argument minus value of minimum arguments
REM Num1, Num2 Num Remainder of Num1/Num2
REVERSE Alph1 or Anum1 or
Nat1
Depends upon argument Reverse order of the characters of the argument
SIGN Num1 Int The sign of Num1
SIN Num1 Num Sine of Num1
SQRT Num1 Num Square root of Num1
STANDARD-DEVIATION Num1 ... Num Standard deviation of arguments
SUM Int1 ... or Num1 ... Depends upon arguments* Sum of arguments
TAN Num1 Num Tangent of Num1
UPPER-CASE Alph1 or Anum1 or
Nat1
Depends upon argument All letters in the argument are set to uppercase
VARIANCE Num1 ... Num Variance of argument
WHEN-COMPILED None Anum Date and time program was compiled
YEAR-TO-YYYY Int1
Int2
Int Argument-1 converted from Int2 YY to YYYY based on the value of argument-2

* A function that has only alphabetic arguments is type alphanumeric.

11.9.1 The ABS Function

The ABS function returns the absolute value of the argument.

The type of this function is according to the argument type as follows:

Argument Type
Function Type
Integer Integer
Numeric Numeric

General Format

Arguments

  1. Argument-1 must be class numeric.

Returned Values

  1. The returned value is as follows:

    1. When the value of argument-1 is zero or positive, (argument-1)

    2. When the value of argument-1 is negative, (-argument-1)

11.9.2 The ACOS Function

The ACOS function returns a numeric value in radians that approximates the arccosine of argument-1. The type of this function is numeric.

General Format

Arguments

  1. Argument-1 must be class numeric.

  2. The value of argument-1 must be greater than or equal to -1 and less than or equal to +1.

Returned Values

  1. The returned value is the approximation of the arccosine of argument-1 and is greater than or equal to zero and less than or equal to pi.

    Note: Conversion factors from radians to degrees and Gon (grad) are specified in the section Trigonometric Functions of this chapter.


  2. Floating-point format is used for numeric non-integer results.

11.9.3 The ANNUITY Function

The ANNUITY function (annuity immediate) returns a numeric value that approximates the ratio of an annuity paid at the end of each period for the number of periods specified by argument-2 to an initial investment of one. Interest is earned at the rate specified by argument-1 and is applied at the end of the period, before the payment. The type of this function is numeric.

General Format

Arguments

  1. Argument-1 must be class numeric.

  2. The value of argument-1 must be greater than or equal to zero.

  3. Argument-2 must be a positive integer.

Returned Values

  1. When the value of argument-1 is zero, the value of the function is the approximation of:

    1 / argument-2

  2. When the value of argument-1 is not zero, the value of the function is the approximation of:

    argument-1 / (1 - (1 + argument-1) ** (- argument-2))

  3. Floating-point format is used for numeric non-integer results.

11.9.4 The ASIN Function

The ASIN function returns a numeric value in radians that approximates the arcsine of argument-1. The type of this function is numeric.

General Format

Arguments

  1. Argument-1 must be class numeric.

  2. The value of argument-1 must be greater than or equal to -1 and less than or equal to +1.

Returned Values

  1. The returned value is the approximation of the arcsine of argument-1 and is greater than or equal to -pi/2 and less than or equal to +pi/2.

    Note: Conversion factors from radians to degrees and Gon (grad) are specified in the section Trigonometric Functions of this chapter.


  2. Floating-point format is used for numeric non-integer results.

11.9.5 The ATAN Function

The ATAN function returns a numeric value in radians that approximates the arctangent of argument-1. The type of this function is numeric.

General Format

Arguments

  1. Argument-1 must be class numeric.

Returned Values

  1. The returned value is the approximation of the arctangent of argument-1 and is greater than -pi/2 and less than +pi/2.

    Note: Conversion factors from radians to degrees and Gon (grad) are specified in the section Trigonometric Functions of this chapter.


  2. Floating-point format is used for numeric non-integer results.

11.9.6 The CHAR Function

The CHAR function returns a one character alphanumeric value that is a character in the program collating sequence having the ordinal position equal to the value of argument-1. The type of this function is alphanumeric.

General Format

Arguments

  1. Argument-1 must be an integer.

  2. The value of argument-1 must be greater than zero and less than or equal to the number of positions in the collating sequence.

Returned Values

  1. If more than one character has the same position in the program collating sequence, the character returned as the function value is that of the first literal specified for that character position in the ALPHABET clause.

  2. If the current program collating sequence was not specified by an ALPHABET clause, the native collating sequence is used.

11.9.7 The CHAR-NATIONAL Function

The CHAR-NATIONAL (national character) function returns a one-character value that is a character in the national program collating sequence having the ordinal position equal to the value of the argument.

The type of the function is national.

General Format

Arguments

  1. Argument-1 must be an integer.

  2. The value of argument-1 must be greater than zero and less than or equal to the number of positions in the national program collating sequence.

Returned Values

  1. The returned value is the character in the national program collating sequence having the ordinal position specifed by argument-1.

  2. If more than one character has the same ordinal positon in the current national program collating sequence, the returned value is the first character defined for that position.

11.9.8 The COS Function

The COS function returns a numeric value that approximates the cosine of an angle or arc, expressed in radians, that is specified by argument-1. The type of this function is numeric.

General Format

Arguments

  1. Argument-1 must be class numeric.

    Note: Conversion factors from degrees and Gon (grad) to radians are specified in the section Trigonometric Functions of this chapter.


Returned Values

  1. The returned value is the approximation of the cosine of argument-1 and is greater than or equal to -1 and less than or equal to +1.

  2. Floating-point format is used for numeric non-integer results.

11.9.9 The CURRENT-DATE Function

The CURRENT-DATE function returns a 21-character alphanumeric value that represents the calendar date, time of day, and local time differential factor provided by the system on which the function is evaluated. The type of this function is alphanumeric.

General Format

Returned Values

  1. The character positions returned, numbered from left to right, are:

    Character Positions
    Contents
    1-4 Four numeric digits of the year in the Gregorian calendar.
    5-6 Two numeric digits of the month of the year, in the range 01 through 12.
    7-8 Two numeric digits of the day of the month, in the range 01 through 31.
    9-10 Two numeric digits of the hours past midnight, in the range 00 through 23.
    11-12 Two numeric digits of the minutes past the hour, in the range 00 through 59.
    13-14 Two numeric digits of the seconds past the minute, in the range 00 through 59.
    15-16 Two numeric digits of the hundredths of a second past the second, in the range 00 through 99.

    If the system does not have the facility to provide fractional parts of a second, the value 00 is returned.

    17 Either the character "–", the character " +", or the character "0". The character "–" is returned if the local time indicated in the previous character positions is behind Greenwich Mean Time. The character "+" is returned if the local time indicated is the same or ahead of Greenwich Mean Time. The character "0" is returned if the system on which this function is evaluated does not have the facility to provide the local time differential factor.

    If the system does not have the facility to provide the local time differential factor, the value 00000 is returned in character positions 17 through 21.

    18-19 If character position 17 is "–", two numeric digits are returned in the range 00 through 12 indicating the number of hours that the reported time is behind Greenwich Mean Time. If character position 17 is "+", two numeric digits are returned in the range 00 through 13 indicating the number of hours that the reported time is ahead of Greenwich Mean Time. If character position 17 is "0", the value 00 is returned.
    20-21 Two numeric digits are returned in the range 00 through 59 indicating the number of additional minutes that the reported time is ahead of or behind Greenwich Mean Time, depending on whether character position 17 is "+" or "–" , respectively. If character position 17 is "0", the value 00 is returned.

11.9.10 The DATE-OF-INTEGER Function

The DATE-OF-INTEGER function converts a date in the Gregorian calendar from integer date form to standard date form (YYYYMMDD). The type of this function is integer.

General Format

Arguments

  1. Argument-1 is a positive integer that represents a number of days succeeding December 31, 1600, in the Gregorian calendar.

Returned Values

  1. The returned value represents the ISO Standard date equivalent of the integer specified in argument-1.

  2. The returned value is in the form (YYYYMMDD) where YYYY represents a year in the Gregorian calendar; MM represents the month of that year; and DD represents the day of that month.

11.9.11 The DATE-TO-YYYYMMDD Function

The DATE-TO-YYYYMMDD function converts argument-1 from the form YYmmdd to the form YYYYmmdd. Argument-2, when added to the year at the time of execution, defines the ending year of a 100-year interval, or sliding window, into which the year of argument-1 falls. The type of this function is integer.

General Format:

      FUNCTION DATE-TO-YYYYMMDD ( argument-1 [argument-2] )

Arguments:

  1. Argument-1 must be a positive integer less than 1,000,000.

  2. Argument-2 must be an integer.

  3. If argument-2 is omitted, the function is evaluated as though 50 were specified.

  4. The sum of the year at the time of execution and the value of argument-2 must be less than 10,000 and greater than 1699.

Returned Values:

  1. The equivalent arithmetic expression is:

    (FUNCTION YEAR-TO-YYYY (YY, argument-2) * 10000 + nnnn) where:

      YY = FUNCTION INTEGER (argument-1/10000)
       nnnn = FUNCTION MOD (argument-1, 10000)

    and where argument-1 of the INTEGER and MOD functions and argument-2 of the YEAR-TO-YYYY function are the same as argument-1 and argument-2 of the DATE-TO-YYYYMMDD function itself.

Notes:

  1. In the year 2002 the returned value for FUNCTION DATE-TO-YYYYMMDD (851003, 10) is 19851003. In the year 1994 the returned value for FUNCTION DATE-TO-YYYYMMDD (981002, (-10)) is 18981002.

  2. This function supports a sliding window algorithm. See the notes for the YEAR-TO-YYYY function for a discussion of how to specify a fixed window.

11.9.12 The DAY-OF-INTEGER Function

The DAY-OF-INTEGER function converts a date in the Gregorian calendar from integer date form to Julian date form (YYYYDDD). The type of this function is integer.

General Format

Arguments

  1. Argument-1 is a positive integer that represents a number of days succeeding December 31, 1600, in the Gregorian calendar.

Returned Values

  1. The returned value represents the Julian equivalent of the integer specified in argument-1.

  2. The returned value is an integer of the form (YYYYDDD) where YYYY represents a year in the Gregorian calendar and DDD represents the day of that year.

11.9.13 The DAY-TO-YYYYDDD Function

The DAY-TO-YYYYDDD function converts argument-1 from the form YYnnn to the form YYYYnnn. Argument-2, when added to the year at the time of execution, defines the ending year of a 100-year interval, or sliding window, into which the year of argument-1 falls. The type of this function is integer.

General Format:

      FUNCTION DAY-TO-YYYYDDD ( argument-1 [argument-2] )

Arguments:

  1. Argument-1 must be a positive integer less than 100,000.

  2. Argument-2 must be an integer.

  3. If argument-2 is omitted, the function is evaluated as though 50 were specified.

  4. The sum of the year at the time of execution and the value of argument-2 must be less than 10,000 and greater than 1699.

Returned Values:

  1. The equivalent arithmetic expression is:

    (FUNCTION YEAR-TO-YYYY (YY, argument-2) * 1000 + nnn)

    where:

      YY = FUNCTION INTEGER (argument-1/1000)
      nnn = FUNCTION MOD (argument-1, 1000)

    and where argument-1 of the INTEGER and MOD functions and argument-2 of the YEAR-TO-YYYY functions are the same as argument-1 and argument-2 of the DAY-TO-YYYYDDD function itself.

Notes:

  1. In the year 2002 the returned value for FUNCTION DAY-TO-YYYYDDD (10004,20) is 2010004. In the year 1994 the returned value for FUNCTION DAY-TO-YYYYDDD (95005, (-10)) is 1895005.

  2. This function supports a sliding window algorithm. See the notes for the YEAR-TO-YYYY function for a discussion of how to specify a fixed window.

11.9.14 The DISPLAY-OF function

The DISPLAY-OF function returns a character string containing the alphanumeric character representation - the external format representation - of the national characters in the argument.

The type of the function is alphanumeric.

General Format

Arguments

  1. Argument-1 shall be of class national.

  2. Argument-2 shall be of class alphabetic or alphanumeric and shall be one character position in length. Argument-2 specifies an alphanumeric substitution character for use in conversion of national characters for which there is no corresponding alphanumeric character.

Returned Values

  1. A character string shall be returned with each national character of argument-1 converted to its corresponding alphanumeric character representation, if any. The correspondence of characters between the alphanumeric character set and the national character set depends on the native environment.

  2. If argument-2 is specified, the alphanumeric substitution character shall be be returned for each national character in argument-1 that has no corresponding alphanumeric character representation.

  3. If argument-2 is unspecified, each national character in argument-1 that has no corresponding alphanumeric character representation shall be returned in national external format, with the minimum of control functions necessary for interpretation of the external format characters.

  4. The length of the returned value shall be the number of character positions of usage display required to hold the returned value; it is dependent on the characters in the argument and on the attributes of the national character set.

11.9.15 The E Function

The E function returns an approximation of e, the base of natural logarithms.

The type of the function is numeric.

General Format

Returned Values

  1. The returned value is:

    2.718281828459045235

11.9.16 EXP Function

The EXP function returns an approximation of the value of e raised to the power of the argument.

The type of the function is numeric.

General Format

Arguments

  1. Argument-1 must be class numeric.

Returned Values

  1. The returned value is:

    FUNCTION E ** argument-1

11.9.17 EXP10 Function

The EXP10 function returns an approximation of the value of 10 raised to the power of the argument.

The type of the function is numeric.

General Format

Arguments

  1. Argument-1 must be class numeric.

Returned Values

  1. The returned value is:

    10 ** argument-1

11.9.18 The FACTORIAL Function

The FACTORIAL function returns an integer that is the factorial of argument-1. The type of this function is integer.

General Format

Arguments

  1. Argument-1 must be an integer greater than or equal to zero.

Returned Values

  1. If the value of argument-1 is zero, the value 1 is returned.

  2. If the value of argument-1 is positive, its factorial is returned.

  3. Floating-point format is used for numeric non-integer results.

11.9.19 The FRACTION-PART Function

The FRACTION-PART function returns a numeric value that is the fraction portion of the argument.

The type of the function is numeric.

General Format

Arguments

  1. Argument-1 must be of the class numeric.

Returned Values

  1. The returned value is:

    (argument-1 - FUNCTION INTEGER-PART (argument-1))

    where the argument for the INTEGER-PART function is the same as for the FRACTION-PART function itself.


Note: If the value of argument-1 is +1.5, +0.5 is returned. If the value of argument-1 is -1.5, -0.5 is returned.


11.9.20 The INTEGER Function

The INTEGER function returns the greatest integer value that is less than or equal to the argument. The type of this function is integer.

General Format

Arguments

  1. Argument-1 must be class numeric.

Returned Values

  1. The returned value is the greatest integer less than or equal to the value of argument-1. For example, if the value of argument-1 is -1.5, -2 is returned. If the value of argument-1 is +1.5, +1 is returned.

11.9.21 The INTEGER-OF-DATE Function

The INTEGER-OF-DATE function converts a date in the Gregorian calendar from standard date form (YYYYMMDD) to integer date form. The type of this function is integer.

General Format

Arguments

  1. Argument-1 must be an integer of the form YYYYMMDD, whose value is obtained from the calculation:

    (YYYY * 10,000) + (MM * 100) + DD.

    1. YYYY represents the year in the Gregorian calendar. It must be an integer greater than 1600.

    2. MM represents a month and must be a positive integer less than 13.

    3. DD represents a day and must be a positive integer less than 32 provided that it is valid for the specified month and year combination.

Returned Values

  1. The returned value is an integer that is the number of days by which the date represented by argument-1 succeeds December 31, 1600, in the Gregorian calendar.

11.9.22 The INTEGER-OF-DAY Function

The INTEGER-OF-DAY function converts a date in the Gregorian calendar from Julian date form (YYYYDDD) to integer date form. The type of this function is integer.

General Format

Arguments

  1. Argument-1 must be an integer of the form YYYYDDD, whose value is obtained from the calculation:

    (YYYY * 1000) + DDD.

    1. YYYY represents the year in the Gregorian calendar. It must be an integer greater than 1600.

    2. DDD represents the day of the year. It must be a positive integer less than 367 provided that it is valid for the year specified.

Returned Values

  1. The returned value is an integer that is the number of days by which the date represented by argument-1 succeeds December 31, 1600, in the Gregorian calendar.

11.9.23 The INTEGER-PART Function

The INTEGER-PART function returns an integer that is the integer portion of argument-1. The type of this function is integer.

General Format

Arguments

  1. Argument-1 must be class numeric.

Returned Values

  1. If the value of argument-1 is zero, the returned value is zero.

  2. If the value of argument-1 is positive, the returned value is the greatest integer less than or equal to the value of argument-1. For example, if the value of argument-1 is +1.5, +1 is returned.

  3. If the value of argument-1 is negative, the returned value is the least integer greater than or equal to the value of argument-1. For example, if the value of argument-1 is -1.5, -1 is returned.

11.9.24 The LENGTH Function

The LENGTH function returns an integer equal to the length of the argument in alphanumeric character positions

or national character positions, depending on the class of the argument.

The type of this function is integer.

General Format

Arguments

  1. Argument-1 can be a nonnumeric literal or a data item of any class or category.

  2. If argument-1 or any data item subordinate to argument-1 is described with the DEPENDING phrase of the OCCURS clause, the contents of the data item referenced by the data-name specified in the DEPENDING phrase are used at the time the LENGTH function is evaluated.

Returned Values

  1. If argument-1 is an elementary data item of the class national or is a national literal, the returned value is an integer equal to the length of argument-1 in national character positions.

  2. Otherwise, if argument-1 is an alphanumeric literal or an elementary data item or argument-1 is a group data item that does not contain a variable occurrence data item, the value returned is an integer equal to the length of argument-1 in alphanumeric character positions.

  3. If argument-1 is a group data item containing a variable occurrence data item, the returned value is an integer determined by evaluation of the data item specified in the DEPENDING phrase of the OCCURS clause for that variable occurrence data item. This evaluation is accomplished according to the rules in the OCCURS clause dealing with the data item as a sending data item. See the sections The OCCURS Clause and The USAGE Clause earlier in this chapter.

  4. The returned value includes implicit FILLER characters, if any.

11.9.25 The LENGTH-AN Function

The LENGTH-AN function returns an integer equal to the length of the argument in number of alphnumeric character positions.

The type of the function is integer.

General Format

Arguments

  1. Argument-1 may be a literal or data item of any class or category.

  2. If argument-1 or any data item subordinate to argument-1 is described with the DEPENDING phrase of the OCCURS clause, the contents of the data item referenced by the data-name specified in the DEPENDING phrase shall be used at the time the LENGTH-AN function is evaluated.

Returned Values

  1. If argument-1 is an elementary data item, the returned value is an integer equal to the length of argument-1 in alphanumeric character positions.

  2. If argument-1 is a group data item:

    1. If argument-1 or any data item subordinate to argument-1 is decribed with the DEPENDING phrase of the OCCURS clause, the returned value is an integer equal to the length of argument-1 in alphanumeric character positions, as a sending data item, determined by evaluation of the data item specified in the DEPENDING phrase in accordance with the rules of the OCCURS clause.

    2. Otherwise the value returned is an integer equal to the lengthof argument-1 in alphanumeric character positions.

    3. The returned length includes the number of implicit FILLER positions, if any, in argument-1.

11.9.26 The LOG Function

The LOG function returns a numeric value that approximates the logarithm to the base e (natural log) of argument-1. The type of this function is numeric.

General Format

Arguments

  1. Argument-1 must be class numeric.

  2. The value of argument-1 must be greater than zero.

Returned Values

  1. The returned value is the approximation of the logarithm to the base e of argument-1.

  2. Floating-point format is used for numeric non-integer results.

11.9.27 The LOG10 Function

The LOG10 function returns a numeric value that approximates the logarithm to the base 10 of argument-1. The type of this function is numeric.

General Format

Arguments

  1. Argument-1 must be class numeric.

  2. The value of argument-1 must be greater than zero.

Returned Values

  1. The returned value is the approximation of the logarithm to the base 10 of argument-1.

  2. Floating-point format is used for numeric non-integer results.

11.9.28 The LOWER-CASE Function

The LOWER-CASE function returns a character string that is the same length as argument-1 with each uppercase letter replaced by the corresponding lowercase letter. The type of this function depends on the argument as follows:

Argument Type
Function Type
Alphabetic Alphanumeric
Alphanumeric Alphanumeric
National National

General Format

Arguments

  1. Argument-1 must be class alphabetic, alphanumeric

    or national

    and must be at least one character in length.

Returned Values

  1. The same character string as argument-1 is returned, except that each uppercase letter is replaced by the corresponding lowercase letter.

  2. The character string returned has the same length as argument-1.

  3. If the computer character set does not include lowercase letters, no changes take place in the character string.

11.9.29 The MAX Function

The MAX function returns the content of the argument-1 that contains the maximum value. The type of this function depends upon the argument types as follows:

Argument Type
Function Type
Alphabetic Alphanumeric
Alphanumeric Alphanumeric
National National
All arguments integer Integer
Numeric Numeric
(some arguments can be integer)

General Format

Arguments

  1. If more than one argument-1 is specified, all arguments must be of the same class except alphabetic and alphanumeric arguments which can be mixed.

Returned Values

  1. The returned value is the content of the argument-1 having the greatest value. The comparisons used to determine the greatest value are made according to the rules for simple conditions. See the section Simple Conditions earlier in this chapter.

  2. If more than one argument-1 has the same greatest value, the content of the argument-1 returned is the leftmost argument-1 having that value.

  3. If the type of the function is alphanumeric

    or national

    the size of the returned value is the same as the size of the selected argument-1.

  4. If the value of argument-1 is numeric non-integer, results are returned in floating-point format.

11.9.30 The MEAN Function

The MEAN function returns a numeric value that is the arithmetic mean (average) of its arguments. The type of this function is numeric.

General Format

Arguments

  1. Argument-1 must be class numeric.

Returned Values

  1. The returned value is the arithmetic mean of the argument-1 series.

  2. The returned value is defined as the sum of the argument-1 series divided by the number of occurrences referenced by argument-1.

  3. Floating-point format is used for numeric non-integer results.

11.9.31 The MEDIAN Function

The MEDIAN function returns the content of the argument whose value is the middle value in the list formed by arranging the arguments in sorted order. The type of this function is numeric.

General Format

Arguments

  1. Argument-1 must be class numeric.

Returned Values

  1. The returned value is the content of the argument-1 having the middle value in the list formed by arranging all the argument-1 values in sorted order.

  2. If the number of occurrences referenced by argument-1 is odd, the returned value is such that at least half of the occurrences referenced by argument-1 are greater than or equal to the returned value and at least half are less than or equal. If the number of occurrences referenced by argument-1 is even, the returned value is the arithmetic mean of the values referenced by the two middle occurrences.

  3. The comparisons used to arrange the argument-1 values in sorted order are made according to the rules for simple conditions. See the section Simple Conditions earlier in this chapter.

  4. Floating-point format is used for numeric non-integer results.

11.9.32 The MIDRANGE Function

The MIDRANGE (middle range) function returns a numeric value that is the arithmetic mean (average) of the values of the minimum argument and the maximum argument. The type of this function is numeric.

General Format

Arguments

  1. Argument-1 must be class numeric.

Returned Values

  1. The returned value is the arithmetic mean of the greatest argument-1 value and the least argument-1 value.

  2. The comparisons used to determine the greatest and least values are made according to the rules for simple conditions. See the section Simple Conditions earlier in this chapter.

  3. Floating-point format is used for numeric non-integer results.

11.9.33 The MIN Function

The MIN function returns the content of the argument-1 that contains the minimum value. The type of this function depends upon the argument types as follows:

Argument Type
Function Type
Alphabetic Alphanumeric
Alphanumeric Alphanumeric
National National
All arguments integer Integer
Numeric Numeric
(some arguments can be integer)

General Format

Arguments

  1. If more than one argument-1 is specified, all arguments must be of the same class except alphabetic and alphanumeric arguments which can be mixed.

Returned Values

  1. The returned value is the content of the argument-1 having the least value. The comparisons used to determine the least value are made according to the rules for simple conditions. See the section Simple Conditions earlier in this chapter.

  2. If more than one argument-1 has the same least value, the content of the argument-1 returned is the leftmost argument-1 having that value.

  3. If the type of the function is alphanumeric

    or national,

    the size of the returned value is the same as the size of the selected argument-1.

  4. If the value of argument-1 is numeric non-integer, results are returned in floating-point format.

11.9.34 The MOD Function

The MOD function returns an integer value that is argument-1 modulo argument-2. The type of this function is integer.

General Format

Arguments

  1. Argument-1 and argument-2 must be integers.

  2. The value of argument-2 must not be zero.

Returned Values

  1. The returned value is argument-1 modulo argument-2. The returned value is defined as:

    argument-1 - (argument-2 * FUNCTION INTEGER (argument-1 / argument-2))

  2. The expected results for some values of argument-1 and argument-2 are as follows:

    Argument-1
    Argument-2
    Return
    11 5 1
    -11 5 4
    11 -5 -4
    -11 -5 -1

11.9.35 The NATIONAL-OF Function

The NATIONAL-OF function returns a character string containing the national character internal representation of the characters in the argument.

The type of the function is national.

General Format

Arguments

  1. Argument-1 shall be of class alphabetic or class alphnumeric. If alphanumeric, it may contain alphanumeric characters or national characters in external format, or both.

  2. Argument-2 shall be of category national and shall be one character in length. Argument-2 specifes a national substitution character for use in conversion of alphanumeric characters for which there is no corresponding national character.

Returned Values

  1. A character string shall be returned with each alphanumeric character and each national character in argument-1 converted to its corresponding national internal format. Any control functions used for external format representation in argument-1 shall be recognised only for purposes of distinguishing characters, and shall not be considered as separate characters of argument-1.

  2. If argument-2 is specified, each character in argument-1 that has no corresponding internal national representation shall be converted to the substitution character specified by argument-2.

  3. If argument-2 is unspecified, each character that has no corresponding internal national representation shall be converted to a national space.

  4. The length of the returned value shall be the number of character positions of usage national required to hold the converted argument and depends on the number of characters contained in argument-1.

11.9.36 The NUMVAL Function

The NUMVAL function returns the numeric value represented by the character string specified by argument-1. Leading and trailing spaces are ignored. The type of this function is numeric.

General Format

Arguments

  1. Argument-1 must be an alphanumeric

    or national

    literal or an alphanumeric

    or national

    data item whose content has one of the following two formats:

    or

    where space is a string of zero or more spaces and digit is a string of one to 18 digits.

  2. The total number of digits in argument-1 must not exceed 18.

  3. If the DECIMAL POINT IS COMMA clause is specified in the SPECIAL-NAMES paragraph, a comma must be used in argument-1 rather than a decimal point.

Returned Values

  1. The returned value is the numeric value represented by argument-1.

  2. The number of digits returned is 18.

  3. Floating-point format is used for numeric non-integer results.

11.9.37 The NUMVAL-C Function

The NUMVAL-C function returns the numeric value represented by the character string specified by argument-1. Any optional currency sign specified by argument-2 and any optional commas preceding the decimal point are ignored. The type of this function is numeric.

General Format

Arguments

  1. Argument-1 must be an alphanumeric

    or national

    literal or an alphanumeric

    or national

    data item whose content has one of the following two formats:

    or

    where space is a string of zero or more spaces, cs is the string of one or more characters specified by argument-2 and digit is a string of one or more digits.

  2. If the DECIMAL POINT IS COMMA clause is specified in the SPECIAL-NAMES paragraph, the functions of the comma and decimal point in argument-1 are reversed.

  3. The total number of digits in argument-1 must not exceed 18.

  4. Argument-2, if specified, must be of the same class as argument-1.

    It cannot be a digit, comma, space, plus sign(+), minus sign (-) or decimal point.

  5. If argument-2 is not specified, the character used for cs is the currency symbol specified for the program when argument-1 is of class alphanumeric

    ; or if argument-1 is of class national, the national representation of the currency symbol specified for the program. The national representation of cs is the value returned from FUNCTION NATIONAL-OF (cs).

Returned Values

  1. The returned value is the numeric value represented by argument-1.

  2. The number of digits returned is 18.

  3. Floating-point format is used for numeric non-integer results.

11.9.38 The ORD Function

The ORD function returns an integer value that is the ordinal position of argument-1 in the collating sequence for the program. The lowest ordinal position is 1. The type of this function is integer.

General Format

Arguments

  1. Argument-1 must be one character in length and must be class alphabetic, alphanumeric

    or national.

Returned Values

  1. If the class of argument-1 is alphabetic or alphanumeric, the returned value is the ordinal position of argument-1 in the current alphanumeric collating sequence for the program.

  2. If the class of argument-1 is national, the returned value is the ordinal position of argument-1 in the current national program collating sequence.

11.9.39 The ORD-MAX Function

The ORD-MAX function returns a value that is the ordinal number of the argument-1 that contains the maximum value. The type of this function is integer.

General Format

Arguments

  1. If more than one argument-1 is specified, all arguments must be of the same class, except alphabetic and alphanumeric arguments which can be mixed.

Returned Values

  1. The returned value is the ordinal number that corresponds to the position of the argument-1 having the greatest value in the argument-1 series.

  2. The comparisons used to determine the greatest valued argument are made according to the rules for simple conditions. See the section Simple Conditions earlier in this chapter.

  3. If more than one argument-1 has the same greatest value, the number returned corresponds to the position of the leftmost argument-1 having that value.

11.9.40 The ORD-MIN Function

The ORD-MIN function returns a value that is the ordinal number of the argument-1 that contains the minimum value. The type of this function is integer.

General Format

Arguments

  1. If more than one argument-1 is specified, all arguments must be of the same class, except alphabetic and alphanumeric arguments which may be mixed.

Returned Values

  1. The returned value is the ordinal number that corresponds to the position of the argument-1 having the lowest value in the argument-1 series.

  2. The comparisons used to determine the lowest valued argument are made according to the rules for simple conditions. See the section Simple Conditions earlier in this chapter.

  3. If more than one argument-1 has the same lowest value, the number returned corresponds to the position of the leftmost argument-1 having that value.

11.9.41 The PI Function

The PI function returns a value that is an approximation of, the ratio of the circumference of a circle to its diameter.

The type of the function is numeric.

General Format

Returned Values

  1. The returned value is:

    3.141592653589793238

11.9.42 The PRESENT-VALUE Function

The PRESENT-VALUE function returns a value that approximates the present value of a series of future period-end amounts specified by argument-2 at a discount rate specified by argument-1. The type of this function is numeric.

General Format

Arguments

  1. Argument-1 and argument-2 must be of the class numeric.

  2. The value of argument-1 must be greater than -1.

Returned Values

  1. The returned value is an approximation of the summation of a series of calculations with each term in the following form:

       argument-2 / (1+argument-1) ** n

    There is one term for each occurrence of argument-2. The exponent, n, is incremented from one by one for each term in the series.

  2. Floating-point format is used for numeric non-integer results.

11.9.43 The RANDOM Function

The RANDOM function returns a numeric value that is a pseudo-random number from a rectangular distribution. The type of this function is numeric.

General Format

Arguments

  1. If argument-1 is specified, it must be zero or a positive integer. It is used as the seed value to generate a sequence of pseudo-random numbers.

  2. If a subsequent reference specifies argument-1, a new sequence of pseudo-random numbers is started.

  3. If the first reference to this function in the run unit does not specify argument-1, the seed value of zero is used.

  4. In each case, subsequent references without specifying argument-1 return the next number in the current sequence.

Returned Values

  1. The returned value is greater than or equal to zero and less than one.

  2. For a given seed value on a given implementation, the sequence of pseudo-random numbers will always be the same.

  3. The domain of argument-1 values will yield distinct sequences of pseudo-random numbers. This subset includes the values from 0 through at least 32767.

  4. Floating-point format is used for numeric non-integer results.

11.9.44 The RANGE Function

The RANGE function returns a value that is equal to the value of the maximum argument minus the value of the minimum argument. The type of this function depends upon the argument types as follows:

Argument Type
Function Type
All arguments integer Integer
Numeric Numeric
(some arguments can be integer)

General Format

Arguments

  1. Argument-1 must be class numeric.

Returned Values

  1. The returned value is equal to the greatest value of argument-1 minus the least value of argument-1.

  2. The comparisons used to determine the greatest and least values are made according to the rules for simple conditions. See the section Simple Conditions earlier in this chapter.

  3. If the value of argument-1 is numeric non-integer, results are returned in floating-point format.

11.9.45 The REM Function

The REM function returns a numeric value that is the remainder of argument-1 divided by argument-2. The type of this function is numeric.

General Format

Arguments

  1. Argument-1 and argument-2 must be class numeric.

  2. The value of argument-2 must not be zero.

Returned Values

  1. The returned value is the remainder of argument-1 / argument-2. It is defined as the expression:

     argument-1 - (argument-2 * FUNCTION INTEGER-PART (argument-1 / argument-2))

  2. Floating-point format is used for numeric non-integer results.

11.9.46 The REVERSE Function

The REVERSE function returns a character string whose length and characters are exactly the same as argument-1, except that the characters are in reverse order. The type of this function depends on the argument type as follows:

Argument Type
Function Type
Alphabetic Alphanumeric
Alphanumeric Alphanumeric
National National

General Format

Arguments

  1. Argument-1 must be class alphabetic, alphanumeric

    or national

    and must be at least one character in length.

Returned Values

  1. If argument-1 is a character string of length n, the returned value is a character string of length n such that for 1 << n, the character in position j of the returned value is the character from position n-j+1 of argument-1.

11.9.47 The SIGN Function

The SIGN function returns +1, 0, or -1 depending on the sign of the argument.

The type of the function is integer.

General Format

Arguments

  1. Argument-1 shall be class numeric.

Returned Values

  1. The returned value is:

    1. When the value of argument-1 is positive, 1

    2. When the value of argument-1 is zero, 0

    3. When the value of argument-1 is negative, -1

11.9.48 The SIN Function

The SIN function returns a numeric value that approximates the sine of an angle or arc, expressed in radians, that is specified by argument-1. The type of this function is numeric.

General Format

Arguments

  1. Argument-1 must be class numeric.


Note: Conversion factors from degrees and Gon (grad) to radians are specified in the section Trigonometric Functions of this chapter.


Returned Values

  1. The returned value is the approximation of the sine of argument-1 and is greater than or equal to -1 and less than or equal to +1.

  2. Floating-point format is used for numeric non-integer results.

11.9.49 The SQRT Function

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

General Format

Arguments

  1. Argument-1 must be class numeric.

  2. The value of argument-1 must be zero or positive.

Returned Values

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

  2. Floating-point format is used for numeric non-integer results.

11.9.50 The STANDARD-DEVIATION Function

The STANDARD-DEVIATION function returns a numeric value that approximates the standard deviation of its arguments. The type of this function is numeric.

General Format

Arguments

  1. Argument-1 must be class numeric.

Returned Values

  1. The returned value is the approximation of the standard deviation of the argument-1 series.

  2. The returned value is calculated as follows:

    1. The difference between each argument-1 value and the arithmetic mean of the argument-1 series is calculated and squared.

    2. The values obtained are added. This quantity is divided by the number of values in the argument-1 series.

    3. The square root of the quotient obtained is calculated. The returned value is the absolute value of this square root.

  3. If the argument-1 series consists of only one value, or if the argument-1 series consists of all variable occurrence data items and the total number of occurrences for all of them is one, the returned value is zero.

  4. Floating-point format is used for numeric non-integer results.

11.9.51 The SUM Function

The SUM function returns a value that is the sum of the arguments. The type of this function depends upon the argument types as follows:

Argument Type
Function Type
All arguments integer Integer
Numeric Numeric
(some arguments may be integer)

General Format

Arguments

  1. Argument-1 must be class numeric.

Returned Values

  1. The returned value is the sum of the arguments.

  2. If the argument-1 series are all integers, the value returned is an integer.

  3. If the argument-1 series are not all integers, a numeric value is returned in floating-point format.

11.9.52 The TAN Function

The TAN function returns a value that approximates the tangent of an angle or arc, expressed in radians, that is specified by argument-1. The type of this function is numeric.

General Format

Arguments

  1. Argument-1 must be class numeric.


Note: Conversion factors from degrees and Gon (grad) to radians are specified in the section Trigonometric Functions of this chapter.


Returned Values

  1. The returned value is the approximation of the tangent of argument-1.

  2. Floating-point format is used for numeric non-integer results.

11.9.53 The UPPER-CASE Function

The UPPER-CASE function returns a character string that is the same length as argument-1 with each lowercase letter replaced by the corresponding uppercase letter. The type of this function depends on the argument as follows:

Argument Type
Function Type
Alphabetic Alphanumeric
Alphanumeric Alphanumeric
National National

General Format

Arguments

  1. Argument-1 must be class alphabetic, alphanumeric

    or national

    and must be at least one character in length.

Returned Values

  1. The same character string as argument-1 is returned, except that each lowercase letter is replaced by the corresponding uppercase letter.

  2. The character string returned has the same length as argument-1.

11.9.54 The VARIANCE Function

The VARIANCE function returns a numeric value that approximates the variance of its arguments. The type of this function is numeric.

General Format

Arguments

  1. Argument-1 must be class numeric.

Returned Values

  1. The returned value is the approximation of the variance of the argument-1 series.

  2. The returned value is defined as the square of the standard deviation of the argument-1 series. (See the section The STANDARD-DEVIATION Function, earlier in this chapter.)

  3. If the argument-1 series consists of only one value, or if the argument-1 series consists of all variable occurrence data items and the total number of occurrences for all of them is one, the returned value is zero.

  4. Floating-point format is used for numeric non-integer results.

11.9.55 The WHEN-COMPILED Function

The WHEN-COMPILED function returns the date and time the program was compiled. The type of this function is alphanumeric.

General Format

Returned Values

  1. The character positions returned, numbered from left to right, are:

    Character Positions
    Contents
    1-4 Four numeric digits of the year in the Gregorian calendar.
    5-6 Two numeric digits of the month of the year, in the range 01 through 12.
    7-8 Two numeric digits of the day of the month, in the range 01 through 31.
    9-10 Two numeric digits of the hours past midnight, in the range 00 through 23.
    11-12 Two numeric digits of the minutes past the hour, in the range 00 through 59.
    13-14 Two numeric digits of the seconds past the minute, in the range 00 through 59.
    15-16 Two numeric digits of the hundredths of a second past the second, in the range 00 through 99.

    If the system does not have the facility to provide fractional parts of a second, the value 00 is returned.

    17 Either the character "–", the character " +", or the character "0". The character "–" is returned if the local time indicated in the previous character positions is behind Greenwich Mean Time. The character "+" is returned if the local time indicated is the same or ahead of Greenwich Mean Time. The character "0" is returned if the system on which this function is evaluated does not have the facility to provide the local time differential factor.

    If the system does not have the facility to provide the local time differential factor, the value 00000 is returned in character positions 17 through 21.

    18-19 If character position 17 is "–", two numeric digits are returned in the range 00 through 12, indicating the number of hours that the reported time is behind Greenwich Mean Time. If character position 17 is "+", two numeric digits are returned in the range 00 through 13 indicating the number of hours that the reported time is ahead of Greenwich Mean Time. If character position 17 is "0", the value 00 is returned.
    20-21 Two numeric digits are returned in the range 00 through 59 indicating the number of additional minutes that the reported time is ahead of or behind Greenwich Mean Time, depending on whether character position 17 is "+" or "–" , respectively.

    If character position 17 is "0", the value 00 is returned.

  2. The returned value is the date and time of compilation of the source program that contains this function. If the program is a contained program, the returned value is the compilation date and time associated with the separately compiled program in which it is contained.

  3. The returned value denotes the same time as the compilation date and time if provided in the listing of the source program and in the generated object code for the source program, although their representations and precisions may differ.

11.9.56 The YEAR-TO-YYYY Function

The YEAR-TO-YYYY function converts argument-1, the two low-order digits of a year, to a four-digit year. Argument-2, when added to the year at the time of execution, defines the ending year of a 100-year interval, or sliding window, into which the year of argument-1 falls. The type of this function is integer.

General Format:

      FUNCTION YEAR-TO-YYYY ( argument-1 [argument-2] )

Arguments:

  1. Argument-1 must be a nonnegative integer less than 100.

  2. Argument-2 must be an integer.

  3. If argument-2 is omitted, the function is evaluated as though 50 were specified.

  4. The sum of the year at the time of execution and the value of argument-2 must be less than 10,000 and greater than 1699.

Returned Values:

  1. Maximum-year is calculated as follows:

    (FUNCTION NUMVAL (FUNCTION CURRENT-DATE (1:4)) + argument-2)

    where argument-2 of the NUMVAL function is the same as argument-2 of the YEAR-TO-YYYY function itself.

  2. The equivalent arithmetic expression is:

    1. When the following condition is true:

      FUNCTION MOD (maximum-year, 100) > = argument-1

      The equivalent arithmetic expression is:

      (argument-1 + 100 * (FUNCTION INTEGER (maximum-year/100)))

    2. Otherwise, the equivalent arithmetic expression is:

      (argument-1 + 100 * (FUNCTION INTEGER (maximum-year/100) - 1))

Notes:

  1. In the year 1995, the returned value for FUNCTION YEAR-TO-YYYY (4, 23) is 2004. In the year 2008 the returned value for FUNCTION YEAR-TO-YYYY (98, (-15)) is 1898.

  2. The YEAR-TO-YYYY function implements a sliding window algorithm. To use it for a fixed window, argument-2 can be specified as follows, where fixed-maximum-year is the maximum year in the fixed 100-year interval:

    (fixed-maximum-year - FUNCTION NUMVAL (FUNCTION CURRENT-DATE (1:4)))

    If the fixed window is 1973 through 2072, then in 2009 argument-2 has the value 63 and in 2019, the value 53.


Copyright © 2000 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names used herein are protected by international law.

PreviousProcedure Division Procedure Division - ACCEPT - DIVIDENext