# median

## Returns the median (middle number) of up to 16
real value arguments.

**Syntax:**

median(val1, val2, ... val15);

Argument |
Description |

val0 ... val15 |
The values to compare. |

**Returns:** Real

### Description

This function returns the median of the input values, that is,
the middle value. When the number of arguments is even, the smaller
of the two middle values is returned and the function can have up
to 16 arguments which must all be real values. This means that, for
example, `median(43, 12, 25, 19, 6)` would return 19 as it
is the middle value between all the rest.

**Example:**

x = median( 0, x, room_width );

y = median( 0, y, room_height );

This will stop the player from exiting any side of the room, by
using median as a clamp. If the player, for instance, moves to the
left of the room boundary, its x will be smaller than 0. This will
mean the middle number of the first of the medians will be 0, so
the player will be jumped to (0,y).

##### © Copyright YoYo Games Ltd. 2015 All Rights Reserved