lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Graham Wilson wrote:

int r = rand()%RAND_MAX;
lua_pushnumber(L, (lua_Number)r / (lua_Number)RAND_MAX);  /* Number between 0 and 1 */
Simple mathematics shows us that this will always push 0. Because:
0 <= r < RAND_MAX and so r/RAND_MAX == 0.

AMDG,
 Antero Vipunen.