diff --git a/luprex/core/cpp/pprint.cpp b/luprex/core/cpp/pprint.cpp index f4d18915..f5efe242 100644 --- a/luprex/core/cpp/pprint.cpp +++ b/luprex/core/cpp/pprint.cpp @@ -14,9 +14,16 @@ void atomic_print(LuaStack &LS, LuaSlot val, std::ostream *os) { // TODO: this could be more efficient. (*os) << LS.ckstring(val); return; - case LUA_TNUMBER: - (*os) << LS.ckinteger(val); + case LUA_TNUMBER: { + double value = LS.cknumber(val); + int64_t ivalue = int64_t(value); + if (double(ivalue) == value) { + (*os) << ivalue; + } else { + (*os) << value; + } return; + } case LUA_TBOOLEAN: (*os) << (LS.ckboolean(val) ? "true" : "false"); return;