Fix a bug printing floats

This commit is contained in:
2021-12-14 10:51:00 -05:00
parent 1116dafc16
commit 1c8c53bd88

View File

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