Skip to content

Commit 0ca29c4

Browse files
authored
Merge pull request #69 from thewtex/consistent-precision
consistent precision
2 parents 37b0809 + 4be44f3 commit 0ca29c4

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

common/load.cc

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ std::string load_string( bool use_colors,
3939
short num_averages )
4040
{
4141
std::ostringstream ss;
42+
ss.setf( std::ios::fixed, std::ios::floatfield );
43+
ss.precision( 2 );
4244
double averages[num_averages];
4345
// based on: opensource.apple.com/source/Libc/Libc-262/gen/getloadavg.c
4446

common/main.cc

+4-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ std::string cpu_string( CPU_MODE cpu_mode, unsigned int cpu_usage_delay, unsigne
8787
oss << "]";
8888
}
8989
oss.width( 5 );
90-
oss << percentage * multiplier;
90+
oss.setf( std::ios::fixed, std::ios::floatfield );
91+
oss.precision( 1 );
92+
oss.fill( ' ' );
93+
oss << std::right << percentage * multiplier;
9194
oss << "%";
9295
if( use_colors )
9396
{

0 commit comments

Comments
 (0)