diff --git a/cclox_src/scanner/object.cc b/cclox_src/scanner/object.cc index 864d1a1..dc14f91 100644 --- a/cclox_src/scanner/object.cc +++ b/cclox_src/scanner/object.cc @@ -1,4 +1,5 @@ #include "object.hh" +#include #include std::string Object::to_string() { @@ -16,7 +17,12 @@ std::string Object::to_string() { } case ObjectType::NUMBER: { double val = std::get(value); - return std::to_string(val); + std::string output{std::to_string(val)}; + if (val == ((int)val)) { + size_t decimal_index{output.find(".")}; + output = output.substr(0, decimal_index); + } + return output; } } }