10 template <
unsigned Base>
13 const auto log = std::log(bytes) / std::log(
Base);
14 unsigned floored =
static_cast<unsigned>(log);
15 for (
unsigned i = 0; i < floored; ++i)
18 if constexpr (
Base == 1024)
20 constexpr const char units[8][4]{
"B",
"KiB",
"MiB",
"GiB",
"TiB",
"PiB",
"EiB",
"ZiB"};
21 return std::to_string(bytes) +
" " + units[floored];
25 constexpr const char units[8][3]{
"b",
"kb",
"mb",
"gb",
"tb",
"pb",
"eb",
"zb"};
26 return std::to_string(bytes) +
" " + units[floored];
Definition range_file_body.hpp:18
std::string bytesToHumanReadable(std::uint64_t bytes)
Definition bytes_to_human_readable.hpp:11