Skip to content

Commit

Permalink
Warning fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Epixu committed Feb 27, 2024
1 parent 2077a0b commit 6a6ae38
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions source/Logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,27 @@ namespace fmt
template<typename FormatContext>
auto format(const Langulus::Size& bs, FormatContext& ctx) {
double f;
if (bs < 1'000LL) f = static_cast<float>(bs);
else if (bs < 1'000'000LL) f = bs * 1. / 1000LL;
else if (bs < 1'000'000'000LL) f = bs * 1. / 1000'000LL;
else if (bs < 1'000'000'000'000LL) f = bs * 1. / 1000'000'000LL;
else if (bs < 1'000'000'000'000'000LL) f = bs * 1. / 1000'000'000'000LL;
else f = bs * 1. / 1000'000'000'000'000LL;
return format_to(ctx.out(), "{:.2f} {}", f, bs.GetSuffix());
if (bs < 1'024LL)
f = static_cast<float>(bs);
else if (bs < 1'048'576LL)
f = bs * 1. / 1'024LL;
else if (bs < 1'073'741'824LL)
f = bs * 1. / 1'048'576LL;
else if constexpr (sizeof(bs) > 4) {
if (bs < 1'099'511'627'776LL)
f = bs * 1. / 1'073'741'824LL;
else if (bs < 1'125'899'906'842'624LL)
f = bs * 1. / 1'099'511'627'776LL;
else
f = bs * 1. / 1'125'899'906'842'624LL;
}
else f = bs * 1. / 1'073'741'824LL;

double intpart;
if (std::modf(f, &intpart) < 0.001)
return format_to(ctx.out(), "{} {}", (::std::size_t) f, bs.GetSuffix());
else
return format_to(ctx.out(), "{:.2f} {}", f, bs.GetSuffix());
}
};

Expand Down

0 comments on commit 6a6ae38

Please sign in to comment.