diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-06-14 15:47:22 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-06-14 15:47:22 -0300 |
commit | aedcfb94144b173a5af52c05c590e9af12b6632b (patch) | |
tree | acaed6e4ed90912089508e18797797dddfbf7f92 /lmathlib.c | |
parent | 992b6d2712c50ba2a20f161aaaddc7225734c5f1 (diff) | |
download | lua-aedcfb94144b173a5af52c05c590e9af12b6632b.tar.gz lua-aedcfb94144b173a5af52c05c590e9af12b6632b.tar.bz2 lua-aedcfb94144b173a5af52c05c590e9af12b6632b.zip |
type 'Rand64' may not be long long, so it should not use 'LL' in its
constants
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; |