Bug Fix - formatBytes
- Corrected code and tests regarding floating point rounding.
This commit is contained in:
@@ -184,9 +184,9 @@ std::string formatBytes (size_t bytes)
|
||||
{
|
||||
char formatted[24];
|
||||
|
||||
if (bytes >= 1000000000) sprintf (formatted, "%.1f GiB", (bytes / 1000000000.0));
|
||||
else if (bytes >= 1000000) sprintf (formatted, "%.1f MiB", (bytes / 1000000.0));
|
||||
else if (bytes >= 1000) sprintf (formatted, "%.1f KiB", (bytes / 1000.0));
|
||||
if (bytes >= 995000000) sprintf (formatted, "%.1f GiB", (bytes / 1000000000.0));
|
||||
else if (bytes >= 995000) sprintf (formatted, "%.1f MiB", (bytes / 1000000.0));
|
||||
else if (bytes >= 995) sprintf (formatted, "%.1f KiB", (bytes / 1000.0));
|
||||
else sprintf (formatted, "%d B", (int)bytes );
|
||||
|
||||
return commify (formatted);
|
||||
|
||||
Reference in New Issue
Block a user