浏览代码

type 'Rand64' may not be long long, so it should not use 'LL' in its
constants

Roberto Ierusalimschy 7 年之前
父节点
当前提交
aedcfb9414
共有 1 个文件被更改,包括 5 次插入4 次删除
  1. 5 4
      lmathlib.c

+ 5 - 4
lmathlib.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lmathlib.c,v 1.133 2018/05/09 14:54:37 roberto Exp roberto $
+** $Id: lmathlib.c,v 1.134 2018/05/16 11:27:59 roberto Exp roberto $
 ** Standard mathematical library
 ** See Copyright Notice in lua.h
 */
@@ -279,7 +279,7 @@ static int math_type (lua_State *L) {
 #elif (LUA_MAXINTEGER >> 31 >> 31) >= 1
 
 /* 'lua_Integer' has at least 64 bits */
-#define Rand64		LUA_UNSIGNED
+#define Rand64		lua_Unsigned
 
 #endif
 
@@ -325,8 +325,9 @@ static Rand64 nextrand (Rand64 *state) {
 ** Convert bits from a random integer into a float in the
 ** interval [0,1).
 */
-#define maskFIG		(~(~1LLU << (FIGS - 1)))  /* use FIGS bits */
-#define shiftFIG	(l_mathop(0.5) / (1LLU << (FIGS - 1)))  /* 2^(-FIGS) */
+#define maskFIG		(~(~(Rand64)1 << (FIGS - 1)))  /* use FIGS bits */
+#define shiftFIG  \
+	(l_mathop(0.5) / ((Rand64)1 << (FIGS - 1)))  /* 2^(-FIGS) */
 
 static lua_Number I2d (Rand64 x) {
   return (lua_Number)(x & maskFIG) * shiftFIG;