Changed: floating_humanizer() now shows fractionals when shortened < 10

This commit is contained in:
aristocratos 2022-02-14 12:45:17 +01:00
parent 4a94c83aa2
commit 2fa800e21e
1 changed files with 3 additions and 1 deletions

View File

@ -360,7 +360,9 @@ namespace Tools {
else if (out.size() >= 2) out.resize(out.size() - 2);
}
if (shorten) {
if (out.find('.') != string::npos) out = to_string((int)round(stof(out)));
auto f_pos = out.find('.');
if (f_pos == 1 and out.size() > 3) out = out.substr(0,2) + to_string((int)round(stof(out.substr(2)) / 10));
else if (f_pos != string::npos) out = to_string((int)round(stof(out)));
if (out.size() > 3) { out = to_string((int)(out[0] - '0') + 1); start++;}
out.push_back(units[start][0]);
}