## Random numbers

### random()

Retrieves the next random value, restricted to a given range.

`random(max);`

Parameters

`max`

- the upper limit of the random number to retrieve.

Returns: a random value between 0 and up to, but not including `max`

.

```
int r = random(10);
// r is >= 0 and < 10
// The smallest value returned is 0
// The largest value returned is 9
```

NB: When `max`

is 0, the result is always 0.

`random(min,max);`

Parameters:

`min`

- the lower limit (inclusive) of the random number to retrieve.`max`

- the upper limit (exclusive) of the random number to retrieve.

Returns: a random value from `min`

and up to, but not including `max`

.

```
int r = random(10, 100);
// r is >= 10 and < 100
// The smallest value returned is 10
// The largest value returned is 99
```

NB: If `min`

is greater or equal to `max`

, the result is always 0.