staticint64_ttoluas_checkint64(lua_State* L, int pos) { int64_t n = 0; int type = lua_type(L, pos);
switch(type) { case LUA_TNUMBER: n = (int64_t)lua_tonumber(L, pos); break; case LUA_TSTRING: n = _long(L, pos); break; case LUA_TUSERDATA: if (_isint64(L, pos)) { n = *(int64_t*)lua_touserdata(L, pos); } break; default: return luaL_typerror(L, pos, "long"); }
return n; }
正确做法:
1 2 3 4
local a = int64.new(1000) local b = 0.01 print(a:toDouble() + b) -- 1000.01 print(a:toDouble() * b) -- 10