Macaw OS C reference

Function rnd

#include <macaw.h>
double rnd(double n);

Gives a random number, for dice, enemy moves and anything else that should change each time.

Parameters

ndouble
The top of the range. A number that isn't a real one (NaN or infinite) counts as 0.

Returns double

A random number from 0 up to, but not including, n, with fractions. flr(rnd(6)) + 1 rolls a dice.

In Handy maths for games, with mid, clamp, sgn, lerp, flr.