summaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lapi.c b/lapi.c
index 516e1b2c..c58ff807 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 2.201 2014/03/12 20:57:40 roberto Exp roberto $ 2** $Id: lapi.c,v 2.202 2014/04/01 18:51:23 roberto Exp roberto $
3** Lua API 3** Lua API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -381,7 +381,7 @@ LUA_API lua_Unsigned lua_tounsignedx (lua_State *L, int idx, int *pisnum) {
381 break; 381 break;
382 } 382 }
383 case LUA_TNUMFLT: { /* compute floor(n) % 2^(numbits in an integer) */ 383 case LUA_TNUMFLT: { /* compute floor(n) % 2^(numbits in an integer) */
384 const lua_Number twop = cast_num(MAX_UINTEGER) + cast_num(1); /* 2^n */ 384 const lua_Number two2n = cast_num(LUA_MAXUNSIGNED) + cast_num(1);
385 lua_Number n = fltvalue(o); /* get value */ 385 lua_Number n = fltvalue(o); /* get value */
386 int neg = 0; 386 int neg = 0;
387 n = l_floor(n); /* get its floor */ 387 n = l_floor(n); /* get its floor */
@@ -389,7 +389,7 @@ LUA_API lua_Unsigned lua_tounsignedx (lua_State *L, int idx, int *pisnum) {
389 neg = 1; 389 neg = 1;
390 n = -n; /* make 'n' positive, so that 'fmod' is the same as '%' */ 390 n = -n; /* make 'n' positive, so that 'fmod' is the same as '%' */
391 } 391 }
392 n = l_mathop(fmod)(n, twop); /* n = n % 2^(numbits in an integer) */ 392 n = l_mathop(fmod)(n, two2n); /* n = n % 2^(numbits in an integer) */
393 if (luai_numisnan(n)) /* not a number? */ 393 if (luai_numisnan(n)) /* not a number? */
394 break; /* not an integer, too */ 394 break; /* not an integer, too */
395 res = cast_unsigned(n); /* 'n' now must fit in an unsigned */ 395 res = cast_unsigned(n); /* 'n' now must fit in an unsigned */