0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 18:22:50 +01:00

ircd::util: Use non-byte unit strings in si util.

This commit is contained in:
Jason Volk 2019-09-22 15:28:36 -07:00
parent 3790c02ec5
commit 62d91f2c94

View file

@ -322,6 +322,23 @@ catch(const std::out_of_range &e)
};
}
ircd::human_readable_size
ircd::util::si(const uint64_t &value)
{
static const std::array<string_view, 7> unit
{
" ", "K", "M", "G", "T", "P", "E"
};
auto pos(0);
long double v(value);
for(; v > 1000.0; v /= 1000.0, ++pos);
return
{
value, v, unit.at(pos)
};
}
ircd::human_readable_size
ircd::util::iec(const uint64_t &value)
{
@ -339,23 +356,6 @@ ircd::util::iec(const uint64_t &value)
};
}
ircd::human_readable_size
ircd::util::si(const uint64_t &value)
{
static const std::array<string_view, 7> unit
{
"B", "KB", "MB", "GB", "TB", "PB", "EB"
};
auto pos(0);
long double v(value);
for(; v > 1000.0; v /= 1000.0, ++pos);
return
{
value, v, unit.at(pos)
};
}
///////////////////////////////////////////////////////////////////////////////
//
// util/string.h