Fix a bug printing floats
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user