(trunk libT) formatter_get_size_str() -- we don't need decimal places when displaying bytes :)

This commit is contained in:
Charles Kerr 2010-06-23 20:14:30 +00:00
parent fa267d9f2b
commit 075169b409
1 changed files with 6 additions and 1 deletions

View File

@ -1580,7 +1580,12 @@ formatter_get_size_str( const struct formatter_units * u,
value = bytes / unit->value; value = bytes / unit->value;
units = unit->name; units = unit->name;
precision = value < 100 ? 2 : 1; if( unit->value == 1 )
precision = 0;
else if( value < 100 )
precision = 2;
else
precision = 1;
tr_snprintf( buf, buflen, "%.*f %s", precision, value, units ); tr_snprintf( buf, buflen, "%.*f %s", precision, value, units );
return buf; return buf;
} }