diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-12-14 16:33:29 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-12-14 16:33:29 -0200 |
| commit | 1b15206cf9aa7005fc3d48f78f60f66838f10eb5 (patch) | |
| tree | 00a96c96d331417ba781b605c6c10d8daae01938 /lmathlib.c | |
| parent | e6d56cd2d844174bd40af4c44c0f68e2115e5876 (diff) | |
| download | lua-1b15206cf9aa7005fc3d48f78f60f66838f10eb5.tar.gz lua-1b15206cf9aa7005fc3d48f78f60f66838f10eb5.tar.bz2 lua-1b15206cf9aa7005fc3d48f78f60f66838f10eb5.zip | |
many details + code redistribution
Diffstat (limited to 'lmathlib.c')
| -rw-r--r-- | lmathlib.c | 4 |
1 files changed, 2 insertions, 2 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lmathlib.c,v 1.20 1999/11/22 13:12:07 roberto Exp roberto $ | 2 | ** $Id: lmathlib.c,v 1.21 1999/11/22 17:39:51 roberto Exp roberto $ |
| 3 | ** Lua standard mathematical library | 3 | ** Lua standard mathematical library |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -144,7 +144,7 @@ static void math_max (lua_State *L) { | |||
| 144 | 144 | ||
| 145 | static void math_random (lua_State *L) { | 145 | static void math_random (lua_State *L) { |
| 146 | /* the '%' avoids the (rare) case of r==1, and is needed also because on | 146 | /* the '%' avoids the (rare) case of r==1, and is needed also because on |
| 147 | some systems (SunOS!) "rand()" may return a value bigger than RAND_MAX */ | 147 | some systems (SunOS!) "rand()" may return a value larger than RAND_MAX */ |
| 148 | double r = (double)(rand()%RAND_MAX) / (double)RAND_MAX; | 148 | double r = (double)(rand()%RAND_MAX) / (double)RAND_MAX; |
| 149 | if (lua_getparam(L, 1) == LUA_NOOBJECT) /* no arguments? */ | 149 | if (lua_getparam(L, 1) == LUA_NOOBJECT) /* no arguments? */ |
| 150 | lua_pushnumber(L, r); /* real between 0 & 1 */ | 150 | lua_pushnumber(L, r); /* real between 0 & 1 */ |
