Display integers with no decimal points
This commit is contained in:
parent
e4723166a2
commit
2690c07220
@ -1,4 +1,5 @@
|
||||
#include "object.hh"
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
|
||||
std::string Object::to_string() {
|
||||
@ -16,7 +17,12 @@ std::string Object::to_string() {
|
||||
}
|
||||
case ObjectType::NUMBER: {
|
||||
double val = std::get<double>(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user