Please enable JavaScript to view this site.

ESL Documentation

MATHLIB Subroutine

Return the median of the values in an integer array.

call MEDIANINT(ARRAY_IV, MEDIAN_VALUE_FV)

ARRAY_IV

An integer array identifier.

MEDIAN_VALUE_FV

The name of a floating point variable to hold the result of the subroutine.

Description

Use this subroutine to return the median of all the values in an integer array. The median is defined as follows:

For an odd number of elements in an array, it is the middle value when all elements are sorted by value.

For an even number of elements in an array, the median is the average of the two middle values after all elements in the array are sorted by value.

The MEDIANINT( ) subroutine makes a copy of the array to sort it. The memory for the temporary array is allocated from local storage, and if this allocation generates an error, the output parameter is set to negative one (-1.0).

Errors

MEDIANINT: memory allocation error; setting value to -1.0.

There is insufficient memory to allocate an array buffer, so the subroutine set MEDIAN_VALUE_FV to -1.0, placed this message in the ESL errorlog, and set errorlevel to 1.0.