Merge pull request #284 from mohi001/main

Fixed: Wrong memory unit when shorten and size is less than 10
This commit is contained in:
Jakob P. Liljenberg 2022-03-07 13:58:10 +01:00 committed by GitHub
commit d14af7f0e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -372,7 +372,7 @@ namespace Tools {
}
if (shorten) {
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));
if (f_pos == 1 and out.size() > 3) out = to_string(round(stof(out) * 10) / 10).substr(0,3);
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]);