1
0
Fork 0
spectre/source/Core/String.cpp

36 lines
649 B
C++

#include <cstdio>
#include <Spectre/Core/String.h>
namespace sp {
std::string core::to_string(int value)
{
char buf[32];
sprintf(buf, "%i", value);
return std::string(buf);
}
std::string core::to_string(unsigned int value)
{
char buf[32];
sprintf(buf, "%u", value);
return std::string(buf);
}
std::string core::to_string(float value)
{
char buf[32];
sprintf(buf, "%f", value);
return std::string(buf);
}
std::string core::to_string(float value, unsigned int precision)
{
char buf[32];
std::string format = "%." + to_string(precision) + "f";
sprintf(buf, format.c_str(), value);
return std::string(buf);
}
} // namespace sp::core