YoYo Games Wiki

median(val1,val2,val3,...)

From YoYoGames Wiki

Description

The median function is a mathematical function in Game Maker that returns the median of the entered arguments. The function can have up to 16 arguments. All arguments must be real.

Arguments

  • val1 (real): the first value
  • val2 (real): the second value
  • val3 (real): the third value
  • ... (real): all additional values (up to 16 total) to find their median.

Returns

(real): the median of all the entered values

Explanation

The median of a collection of values is the middle values in the usual order. When the number of arguments is even the smaller of the two middle values is returned.

Examples

median(5,8,20);

returns 8

median(8,6,7,5,4,2);

returns 5

See Also