diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2007-03-27 09:37:00 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2007-03-27 09:37:00 -0300 |
| commit | 8e36e1fe4928c60a09573a850e6807d922a56664 (patch) | |
| tree | 21f48eed170de4d437629ba8818552725bfae849 | |
| parent | 97505caa64aa82aab635f7135aaba8b5ef857e52 (diff) | |
| download | lua-8e36e1fe4928c60a09573a850e6807d922a56664.tar.gz lua-8e36e1fe4928c60a09573a850e6807d922a56664.tar.bz2 lua-8e36e1fe4928c60a09573a850e6807d922a56664.zip | |
details (randomseed calls rand once to dischard first value)
| -rw-r--r-- | lmathlib.c | 3 |
1 files changed, 2 insertions, 1 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lmathlib.c,v 1.67 2005/08/26 17:36:32 roberto Exp roberto $ | 2 | ** $Id: lmathlib.c,v 1.68 2006/08/07 19:01:56 roberto Exp roberto $ |
| 3 | ** Standard mathematical library | 3 | ** Standard mathematical library |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -211,6 +211,7 @@ static int math_random (lua_State *L) { | |||
| 211 | 211 | ||
| 212 | static int math_randomseed (lua_State *L) { | 212 | static int math_randomseed (lua_State *L) { |
| 213 | srand(luaL_checkint(L, 1)); | 213 | srand(luaL_checkint(L, 1)); |
| 214 | (void)rand(); /* discard first value to avoid undesirable correlations */ | ||
| 214 | return 0; | 215 | return 0; |
| 215 | } | 216 | } |
| 216 | 217 | ||
