diff options
-rw-r--r-- | AK/String.cpp | 32 | ||||
-rw-r--r-- | AK/String.h | 19 |
2 files changed, 31 insertions, 20 deletions
diff --git a/AK/String.cpp b/AK/String.cpp index 8922a2a543..3ad0ba0a33 100644 --- a/AK/String.cpp +++ b/AK/String.cpp @@ -230,26 +230,44 @@ unsigned String::to_uint(bool& ok) const return value; } -String String::number(u64 value) +String String::number(unsigned long long value) { int size; char buffer[32]; -#ifdef __serenity__ size = sprintf(buffer, "%llu", value); -#else - size = sprintf(buffer, "%" PRIu64, value); -#endif return String(buffer, size); } -String String::number(u32 value) +String String::number(unsigned long value) +{ + int size; + char buffer[32]; + size = sprintf(buffer, "%lu", value); + return String(buffer, size); +} + +String String::number(unsigned value) { char buffer[32]; int size = sprintf(buffer, "%u", value); return String(buffer, size); } -String String::number(i32 value) +String String::number(long long value) +{ + char buffer[32]; + int size = sprintf(buffer, "%lld", value); + return String(buffer, size); +} + +String String::number(long value) +{ + char buffer[32]; + int size = sprintf(buffer, "%ld", value); + return String(buffer, size); +} + +String String::number(int value) { char buffer[32]; int size = sprintf(buffer, "%d", value); diff --git a/AK/String.h b/AK/String.h index a4f1593a76..74ac6a885d 100644 --- a/AK/String.h +++ b/AK/String.h @@ -231,19 +231,12 @@ public: } static String format(const char*, ...); - static String number(u64); - static String number(u32); - static String number(i32); - static String number(i64); - - static String number(size_t n) - { - if constexpr(sizeof(size_t) == 4) - return number((u32)n); - else if constexpr(sizeof(size_t) == 8) - return number((u64)n); - ASSERT_NOT_REACHED(); - } + static String number(unsigned); + static String number(unsigned long); + static String number(unsigned long long); + static String number(int); + static String number(long); + static String number(long long); StringView view() const { |