diff options
-rw-r--r-- | lmathlib.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lmathlib.c,v 1.12 1998/12/28 13:44:54 roberto Exp roberto $ | 2 | ** $Id: lmathlib.c,v 1.13 1998/12/30 17:22:17 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 | */ |
@@ -154,9 +154,9 @@ static void math_max (void) | |||
154 | 154 | ||
155 | 155 | ||
156 | static void math_random (void) { | 156 | static void math_random (void) { |
157 | /* the '%' is needed because on some systems (SunOS!) "rand()" may | 157 | /* the '%' avoids the (rare) case of r==1, and is needed also because on |
158 | return a value bigger than RAND_MAX... */ | 158 | some systems (SunOS!) "rand()" may return a value bigger than RAND_MAX */ |
159 | double r = (double)(rand()%RAND_MAX) / ((double)RAND_MAX+1.0); | 159 | double r = (double)(rand()%RAND_MAX) / (double)RAND_MAX; |
160 | int l = luaL_opt_int(1, 0); | 160 | int l = luaL_opt_int(1, 0); |
161 | if (l == 0) | 161 | if (l == 0) |
162 | lua_pushnumber(r); | 162 | lua_pushnumber(r); |