Skip to content

Commit

Permalink
Merge pull request #69 from thewtex/consistent-precision
Browse files Browse the repository at this point in the history
consistent precision
  • Loading branch information
thewtex authored Aug 3, 2021
2 parents 37b0809 + 4be44f3 commit 0ca29c4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions common/load.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ std::string load_string( bool use_colors,
short num_averages )
{
std::ostringstream ss;
ss.setf( std::ios::fixed, std::ios::floatfield );
ss.precision( 2 );
double averages[num_averages];
// based on: opensource.apple.com/source/Libc/Libc-262/gen/getloadavg.c

Expand Down
5 changes: 4 additions & 1 deletion common/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down

0 comments on commit 0ca29c4

Please sign in to comment.