1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 02:57:44 +00:00

AK: Rename KB, MB, GB to KiB, MiB, GiB

The SI prefixes "k", "M", "G" mean "10^3", "10^6", "10^9".
The IEC prefixes "Ki", "Mi", "Gi" mean "2^10", "2^20", "2^30".

Let's use the correct name, at least in code.

Only changes the name of the constants, no other behavior change.
This commit is contained in:
Nico Weber 2020-08-15 13:55:00 -04:00 committed by Andreas Kling
parent a68650a7b4
commit 430b265cd4
31 changed files with 69 additions and 69 deletions

View file

@ -39,13 +39,13 @@ static String number_string_with_one_decimal(float number, const char* suffix)
static String human_readable_size(size_t size)
{
if (size < 1 * KB)
if (size < 1 * KiB)
return String::format("%zu bytes", size);
if (size < 1 * MB)
return number_string_with_one_decimal((float)size / (float)KB, "KB");
if (size < 1 * GB)
return number_string_with_one_decimal((float)size / (float)MB, "MB");
return number_string_with_one_decimal((float)size / (float)GB, "GB");
if (size < 1 * MiB)
return number_string_with_one_decimal((float)size / (float)KiB, "KB");
if (size < 1 * GiB)
return number_string_with_one_decimal((float)size / (float)MiB, "MB");
return number_string_with_one_decimal((float)size / (float)GiB, "GB");
}
}

View file

@ -74,9 +74,9 @@ typedef __PTRDIFF_TYPE__ __ptrdiff_t;
typedef Conditional<sizeof(void*) == 8, u64, u32>::Type FlatPtr;
constexpr unsigned KB = 1024;
constexpr unsigned MB = KB * KB;
constexpr unsigned GB = KB * KB * KB;
constexpr unsigned KiB = 1024;
constexpr unsigned MiB = KiB * KiB;
constexpr unsigned GiB = KiB * KiB * KiB;
namespace std {
typedef decltype(nullptr) nullptr_t;