#include "utils/utils.hpp" #include #include void format_rate(std::string & s, double rate) { static const char MAX_FORMAT[] = "00000.00"; if(std::isinf(rate) || std::isnan(rate)) { rate = 0.0; } s.resize(sizeof(MAX_FORMAT)); int wrlen = snprintf(&s[0], s.size(), "%05.2f", rate); int sz = strlen(s.c_str()); if(sz != wrlen) { s.assign("ERR"); } else { s.resize(sz); } }