diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-04-27 11:41:11 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-04-27 11:41:11 -0300 |
commit | e98ba351cebaec72f56acceddd82338cc37c3265 (patch) | |
tree | ed72629b9b4002fea51848d49b8b56310ca37d8d /lobject.c | |
parent | cbe4998bc29d5b98636f39cad5812c77a4fc2d77 (diff) | |
download | lua-e98ba351cebaec72f56acceddd82338cc37c3265.tar.gz lua-e98ba351cebaec72f56acceddd82338cc37c3265.tar.bz2 lua-e98ba351cebaec72f56acceddd82338cc37c3265.zip |
n^-m gives float result (instead of error)
Diffstat (limited to 'lobject.c')
-rw-r--r-- | lobject.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lobject.c,v 2.79 2014/04/15 14:28:20 roberto Exp roberto $ | 2 | ** $Id: lobject.c,v 2.80 2014/04/15 16:32:49 roberto Exp roberto $ |
3 | ** Some generic functions over Lua objects | 3 | ** Some generic functions over Lua objects |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -77,7 +77,7 @@ static lua_Integer intarith (lua_State *L, int op, lua_Integer v1, | |||
77 | case LUA_OPSUB:return intop(-, v1, v2); | 77 | case LUA_OPSUB:return intop(-, v1, v2); |
78 | case LUA_OPMUL:return intop(*, v1, v2); | 78 | case LUA_OPMUL:return intop(*, v1, v2); |
79 | case LUA_OPMOD: return luaV_mod(L, v1, v2); | 79 | case LUA_OPMOD: return luaV_mod(L, v1, v2); |
80 | case LUA_OPPOW: return luaV_pow(L, v1, v2); | 80 | case LUA_OPPOW: return luaV_pow(v1, v2); |
81 | case LUA_OPIDIV: return luaV_div(L, v1, v2); | 81 | case LUA_OPIDIV: return luaV_div(L, v1, v2); |
82 | case LUA_OPBAND: return intop(&, v1, v2); | 82 | case LUA_OPBAND: return intop(&, v1, v2); |
83 | case LUA_OPBOR: return intop(|, v1, v2); | 83 | case LUA_OPBOR: return intop(|, v1, v2); |
@@ -133,7 +133,8 @@ void luaO_arith (lua_State *L, int op, const TValue *p1, const TValue *p2, | |||
133 | } | 133 | } |
134 | default: { /* other operations */ | 134 | default: { /* other operations */ |
135 | lua_Number n1; lua_Number n2; | 135 | lua_Number n1; lua_Number n2; |
136 | if (ttisinteger(p1) && ttisinteger(p2)) { | 136 | if (ttisinteger(p1) && ttisinteger(p2) && |
137 | (op != LUA_OPPOW || ivalue(p2) >= 0)) { | ||
137 | setivalue(res, intarith(L, op, ivalue(p1), ivalue(p2))); | 138 | setivalue(res, intarith(L, op, ivalue(p1), ivalue(p2))); |
138 | return; | 139 | return; |
139 | } | 140 | } |