more explicit casts when converting an integer to a random float
(to ensure computations are done with all bits)
diff --git a/lmathlib.c b/lmathlib.c
index 2b5fd46..b60c661 100644
--- a/lmathlib.c
+++ b/lmathlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lmathlib.c,v 1.122 2018/03/09 15:05:13 roberto Exp roberto $
+** $Id: lmathlib.c,v 1.123 2018/03/09 19:23:39 roberto Exp roberto $
** Standard mathematical library
** See Copyright Notice in lua.h
*/
@@ -373,7 +373,7 @@
/* do not need bits from higher half */
#define maskHF 0
#define maskLOW (~(~1U << (FIGS - 1))) /* use FIG bits */
-#define shiftFIG (0.5 / (1U << (FIGS - 1))) /* 2^(-FIG) */
+#define shiftFIG (l_mathop(0.5) / (1U << (FIGS - 1))) /* 2^(-FIG) */
#else /* 32 < FIGS <= 64 */
@@ -393,7 +393,9 @@
#define twoto32 l_mathop(4294967296.0) /* 2^32 */
static lua_Number I2d (I x) {
- return ((x.h & maskHF) * twoto32 + (x.l & maskLOW)) * shiftFIG;
+ lua_Number h = (lua_Number)(x.h & maskHF);
+ lua_Number l = (lua_Number)(x.l & maskLOW);
+ return (h * twoto32 + l) * shiftFIG;
}
static lua_Unsigned I2UInt (I x) {