diff options
Diffstat (limited to 'lmathlib.c')
-rw-r--r-- | lmathlib.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lmathlib.c,v 1.133 2018/05/09 14:54:37 roberto Exp roberto $ | 2 | ** $Id: lmathlib.c,v 1.134 2018/05/16 11:27:59 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 | */ |
@@ -279,7 +279,7 @@ static int math_type (lua_State *L) { | |||
279 | #elif (LUA_MAXINTEGER >> 31 >> 31) >= 1 | 279 | #elif (LUA_MAXINTEGER >> 31 >> 31) >= 1 |
280 | 280 | ||
281 | /* 'lua_Integer' has at least 64 bits */ | 281 | /* 'lua_Integer' has at least 64 bits */ |
282 | #define Rand64 LUA_UNSIGNED | 282 | #define Rand64 lua_Unsigned |
283 | 283 | ||
284 | #endif | 284 | #endif |
285 | 285 | ||
@@ -325,8 +325,9 @@ static Rand64 nextrand (Rand64 *state) { | |||
325 | ** Convert bits from a random integer into a float in the | 325 | ** Convert bits from a random integer into a float in the |
326 | ** interval [0,1). | 326 | ** interval [0,1). |
327 | */ | 327 | */ |
328 | #define maskFIG (~(~1LLU << (FIGS - 1))) /* use FIGS bits */ | 328 | #define maskFIG (~(~(Rand64)1 << (FIGS - 1))) /* use FIGS bits */ |
329 | #define shiftFIG (l_mathop(0.5) / (1LLU << (FIGS - 1))) /* 2^(-FIGS) */ | 329 | #define shiftFIG \ |
330 | (l_mathop(0.5) / ((Rand64)1 << (FIGS - 1))) /* 2^(-FIGS) */ | ||
330 | 331 | ||
331 | static lua_Number I2d (Rand64 x) { | 332 | static lua_Number I2d (Rand64 x) { |
332 | return (lua_Number)(x & maskFIG) * shiftFIG; | 333 | return (lua_Number)(x & maskFIG) * shiftFIG; |