General Formats (Continued) [ Micro Focus COBOL Language Reference ] MPE/iX 5.0 Documentation
Micro Focus COBOL Language Reference
General Formats (Continued)
For ANS85: Intrinsic Functions (Continued)
For ANS85 only: The DAY-OF-INTEGER Function.
Description.
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.
Argument.
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.
For ANS85 only: The FACTORIAL Function.
Description.
The FACTORIAL function returns an integer that is the factorial of
argument-1. The type of this function is integer.
General Format.
Argument.
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.
For ANS85 only: The INTEGER Function.
Description.
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.
Argument.
Argument-1 must be class numeric.
Returned Value.
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.
For ANS85 only: The INTEGER-OF-DATE Function.
Description.
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.
Argument.
Argument-1 must be an integer of the form YYYYMMDD, whose value is
obtained from the calculation:
(YYYY * 10,000) + (MM * 100) + DD.
a. YYYY represents the year in the Gregorian calendar. It must be an
integer greater than 1600.
b. MM represents a month and must be a positive integer less than 13.
c. 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 Value.
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.
For ANS85 only: The INTEGER-OF-DAY Function.
Description.
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.
Argument.
Argument-1 must be an integer of the form YYYYDDD, whose value is
obtained from the calculation:
(YYYY * 1000) + DDD.
a. YYYY represents the year in the Gregorian calendar. It must be an
integer greater than 1600.
b. 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 Value.
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.
For ANS85 only: The INTEGER-PART Function.
Description.
The INTEGER-PART function returns an integer that is the integer portion
of argument-1. The type of this function is integer.
General Format.
Argument.
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.
For ANS85 only: The LENGTH Function.
Description.
The LENGTH function returns an integer equal to the length of the
argument in character positions. 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.
For MF only: It must not be DBCS.
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 a nonnumeric 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 character positions.
2. 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.
3. The returned value includes implicit FILLER characters, if any.
For ANS85 only: The LOG Function.
Description.
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.
For ANS85 only: The LOG10 Function.
Description.
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.
For ANS85 only: The LOWER-CASE Function.
Description.
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 is
alphanumeric.
General Format.
Argument.
Argument-1 must be class alphabetic or alphanumeric 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.
For ANS85 only: The MAX Function.
Description.
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
All arguments integer Integer
Numeric Numeric
(some arguments can be integer)
General Format.
Argument.
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, 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.
For ANS85 only: The MEAN Function.
Description.
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.
Argument.
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.
For ANS85 only: The MEDIAN Function.
Description.
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.
Argument.
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.
For ANS85 only: The MIDRANGE Function.
Description.
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.
Argument.
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.
For ANS85 only: The MIN Function.
Description.
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
All arguments integer Integer
Numeric Numeric
(some arguments can be integer)
General Format.
Argument.
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, 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.
For ANS85 only: The MOD Function.
Description.
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
2. The returned value is defined as:
argument-1 - (argument-2 * FUNCTION INTEGER (argument-1 /
argument-2))
3. 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
For ANS85 only: The NUMVAL Function.
Description.
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 a nonnumeric literal or alphanumeric data item
whose content has one of the following two formats:
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.
For ANS85 only: The NUMVAL-C Function.
Description.
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 a nonnumeric literal or alphanumeric data item
whose content has one of the following two formats:
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 a nonnumeric literal or
alphanumeric data item.
For MF only: 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.
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.
MPE/iX 5.0 Documentation