mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-04-10 18:28:54 +02:00
[qt, util] Change default units from units of 1024 (MiB, KiB) to 1000 (MB, KB) (#2882)
Better for readability of these units? Perhaps Signed-off-by: lizzie <lizzie@eden-emu.dev> Co-authored-by: crueter <crueter@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2882 Reviewed-by: crueter <crueter@eden-emu.dev> Reviewed-by: Maufeat <sahyno1996@gmail.com> Reviewed-by: Caio Oliveira <caiooliveirafarias0@gmail.com> Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
parent
4cc9aa691d
commit
3141019fcd
3 changed files with 9 additions and 22 deletions
|
|
@ -49,16 +49,13 @@ u64 ClearDir(DataDir dir, const std::string &user_id)
|
|||
return result;
|
||||
}
|
||||
|
||||
const std::string ReadableBytesSize(u64 size)
|
||||
{
|
||||
static constexpr std::array units{"B", "KiB", "MiB", "GiB", "TiB", "PiB"};
|
||||
if (size == 0) {
|
||||
std::string ReadableBytesSize(u64 size) noexcept {
|
||||
std::array<std::string_view, 6> const units{"B", "KB", "MB", "GB", "TB", "PB"};
|
||||
u64 const base = 1000;
|
||||
if (size == 0)
|
||||
return "0 B";
|
||||
}
|
||||
|
||||
const int digit_groups = (std::min) (static_cast<int>(std::log10(size) / std::log10(1024)),
|
||||
static_cast<int>(units.size()));
|
||||
return fmt::format("{:.1f} {}", size / std::pow(1024, digit_groups), units[digit_groups]);
|
||||
auto const digit_groups = std::min<u64>(u64(std::log10(size) / std::log10(base)), u64(units.size()));
|
||||
return fmt::format("{:.1f} {}", size / std::pow(base, digit_groups), units[digit_groups]);
|
||||
}
|
||||
|
||||
u64 DataDirSize(DataDir dir)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue