diff options
Diffstat (limited to 'lmathlib.c')
-rw-r--r-- | lmathlib.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lmathlib.c,v 1.122 2018/03/09 15:05:13 roberto Exp roberto $ | 2 | ** $Id: lmathlib.c,v 1.123 2018/03/09 19:23:39 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 | */ |
@@ -373,7 +373,7 @@ static I xorshift128plus (I *state) { | |||
373 | /* do not need bits from higher half */ | 373 | /* do not need bits from higher half */ |
374 | #define maskHF 0 | 374 | #define maskHF 0 |
375 | #define maskLOW (~(~1U << (FIGS - 1))) /* use FIG bits */ | 375 | #define maskLOW (~(~1U << (FIGS - 1))) /* use FIG bits */ |
376 | #define shiftFIG (0.5 / (1U << (FIGS - 1))) /* 2^(-FIG) */ | 376 | #define shiftFIG (l_mathop(0.5) / (1U << (FIGS - 1))) /* 2^(-FIG) */ |
377 | 377 | ||
378 | #else /* 32 < FIGS <= 64 */ | 378 | #else /* 32 < FIGS <= 64 */ |
379 | 379 | ||
@@ -393,7 +393,9 @@ static I xorshift128plus (I *state) { | |||
393 | #define twoto32 l_mathop(4294967296.0) /* 2^32 */ | 393 | #define twoto32 l_mathop(4294967296.0) /* 2^32 */ |
394 | 394 | ||
395 | static lua_Number I2d (I x) { | 395 | static lua_Number I2d (I x) { |
396 | return ((x.h & maskHF) * twoto32 + (x.l & maskLOW)) * shiftFIG; | 396 | lua_Number h = (lua_Number)(x.h & maskHF); |
397 | lua_Number l = (lua_Number)(x.l & maskLOW); | ||
398 | return (h * twoto32 + l) * shiftFIG; | ||
397 | } | 399 | } |
398 | 400 | ||
399 | static lua_Unsigned I2UInt (I x) { | 401 | static lua_Unsigned I2UInt (I x) { |