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:
parent
3790c02ec5
commit
62d91f2c94
1 changed files with 17 additions and 17 deletions
34
ircd/util.cc
34
ircd/util.cc
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue