From 4be44f35f7225f1febf317f2c28c74deee6e09d4 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 3 Aug 2021 18:38:28 -0400 Subject: [PATCH] Specify precision in CPU percent output More consistent formatting. --- common/main.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/main.cc b/common/main.cc index a792c62..fa68ee1 100644 --- a/common/main.cc +++ b/common/main.cc @@ -87,7 +87,10 @@ std::string cpu_string( CPU_MODE cpu_mode, unsigned int cpu_usage_delay, unsigne oss << "]"; } oss.width( 5 ); - oss << percentage * multiplier; + oss.setf( std::ios::fixed, std::ios::floatfield ); + oss.precision( 1 ); + oss.fill( ' ' ); + oss << std::right << percentage * multiplier; oss << "%"; if( use_colors ) {