aboutsummaryrefslogtreecommitdiff
path: root/lvm.c
diff options
context:
space:
mode:
Diffstat (limited to 'lvm.c')
-rw-r--r--lvm.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/lvm.c b/lvm.c
index e92757a0..d5366428 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 2.210 2014/05/14 19:47:11 roberto Exp roberto $ 2** $Id: lvm.c,v 2.211 2014/05/15 20:08:32 roberto Exp roberto $
3** Lua virtual machine 3** Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -452,7 +452,8 @@ void luaV_objlen (lua_State *L, StkId ra, const TValue *rb) {
452 452
453 453
454/* 454/*
455** Integer division; return 'm // n'. 455** Integer division; return 'm // n'. (Assume that C division with
456** negative operands follows C99 behavior.)
456*/ 457*/
457lua_Integer luaV_div (lua_State *L, lua_Integer m, lua_Integer n) { 458lua_Integer luaV_div (lua_State *L, lua_Integer m, lua_Integer n) {
458 if (l_castS2U(n) + 1u <= 1u) { /* special cases: -1 or 0 */ 459 if (l_castS2U(n) + 1u <= 1u) { /* special cases: -1 or 0 */
@@ -471,7 +472,8 @@ lua_Integer luaV_div (lua_State *L, lua_Integer m, lua_Integer n) {
471 472
472 473
473/* 474/*
474** Integer modulus; return 'm % n'. 475** Integer modulus; return 'm % n'. (Assume that C '%' with
476** negative operands follows C99 behavior.)
475*/ 477*/
476lua_Integer luaV_mod (lua_State *L, lua_Integer m, lua_Integer n) { 478lua_Integer luaV_mod (lua_State *L, lua_Integer m, lua_Integer n) {
477 if (l_castS2U(n) + 1u <= 1u) { /* special cases: -1 or 0 */ 479 if (l_castS2U(n) + 1u <= 1u) { /* special cases: -1 or 0 */
@@ -481,7 +483,7 @@ lua_Integer luaV_mod (lua_State *L, lua_Integer m, lua_Integer n) {
481 } 483 }
482 else { 484 else {
483 lua_Integer r = m % n; 485 lua_Integer r = m % n;
484 if (r == 0 || (m ^ n) >= 0) 486 if (r == 0 || (m ^ n) >= 0) /* no rest or same signal? */
485 return r; 487 return r;
486 else 488 else
487 return r + n; /* correct 'mod' for negative case */ 489 return r + n; /* correct 'mod' for negative case */