Skip to content

Commit

Permalink
Switch to Binary Size Prefixes (e.g., "MB" -> "MiB")
Browse files Browse the repository at this point in the history
Suggested by @aqrit, a little more verbose, but hopefully addresses a real
ambiguity.
  • Loading branch information
felixhandte committed Jun 10, 2021
1 parent c8040d6 commit 9b17550
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions programs/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ UTIL_HumanReadableSize_t UTIL_makeHumanReadableSize(U64 size) {
* values that exceed the integral precision of a double. */
if (size >= (1ull << 53)) {
hrs.value = (double)size / (1ull << 20);
hrs.suffix = " MB";
hrs.suffix = " MiB";
/* At worst, a double representation of a maximal size will be
* accurate to better than tens of kilobytes. */
hrs.precision = 2;
Expand All @@ -324,22 +324,22 @@ UTIL_HumanReadableSize_t UTIL_makeHumanReadableSize(U64 size) {
/* In regular mode, scale sizes down and use suffixes. */
if (size >= (1ull << 60)) {
hrs.value = (double)size / (1ull << 60);
hrs.suffix = " EB";
hrs.suffix = " EiB";
} else if (size >= (1ull << 50)) {
hrs.value = (double)size / (1ull << 50);
hrs.suffix = " PB";
hrs.suffix = " PiB";
} else if (size >= (1ull << 40)) {
hrs.value = (double)size / (1ull << 40);
hrs.suffix = " TB";
hrs.suffix = " TiB";
} else if (size >= (1ull << 30)) {
hrs.value = (double)size / (1ull << 30);
hrs.suffix = " GB";
hrs.suffix = " GiB";
} else if (size >= (1ull << 20)) {
hrs.value = (double)size / (1ull << 20);
hrs.suffix = " MB";
hrs.suffix = " MiB";
} else if (size >= (1ull << 10)) {
hrs.value = (double)size / (1ull << 10);
hrs.suffix = " KB";
hrs.suffix = " KiB";
} else {
hrs.value = (double)size;
hrs.suffix = " B";
Expand Down

0 comments on commit 9b17550

Please sign in to comment.