From c6c08708ec654f4f3ac6138cf0ab506f280d0335 Mon Sep 17 00:00:00 2001 From: mohammad hashemy Date: Mon, 7 Mar 2022 15:56:15 +0330 Subject: [PATCH] Fixed: Wrong memory unit when shorten and size is less than 10 --- src/btop_tools.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/btop_tools.cpp b/src/btop_tools.cpp index e3d0597..301e554 100644 --- a/src/btop_tools.cpp +++ b/src/btop_tools.cpp @@ -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]);