diff --git a/openVulkanoCpp/Math/ByteSize.hpp b/openVulkanoCpp/Math/ByteSize.hpp index 10107e8..a158af1 100644 --- a/openVulkanoCpp/Math/ByteSize.hpp +++ b/openVulkanoCpp/Math/ByteSize.hpp @@ -57,7 +57,7 @@ namespace openVulkanoCpp static constexpr std::array FACTORS = ByteSizeUnitHelper::BuildFactors(); static constexpr std::array DIVISORS = ByteSizeUnitHelper::BuildDivisors(); public: - enum Unit : int { B, kiB, MiB, GiB, TiB, PiB, EiB, kB, MB, GB, TB, PB, EB }; + enum Unit : int { B = 0, kiB, MiB, GiB, TiB, PiB, EiB, kB, MB, GB, TB, PB, EB }; constexpr ByteSizeUnit(Unit unit) : unit(unit) {} @@ -79,7 +79,7 @@ namespace openVulkanoCpp [[nodiscard]] static constexpr ByteSizeUnit GetClosestUnit(uint64_t size, bool si = false) { - for (int i = (si ? EB : EiB); i <= (si ? kB : kiB); i--) + for (int i = (si ? EB : EiB); i >= (si ? kB : kiB); i--) { if (size > FACTORS[i]) return { static_cast(i) }; } @@ -118,7 +118,7 @@ namespace openVulkanoCpp { oss << std::setprecision(3); auto unit = ByteSizeUnit::GetClosestUnit(bytes, si); - oss << bytes * unit.GetDivisor() << ' ' << unit.GetName(); + oss << static_cast(bytes) * unit.GetDivisor() << ' ' << unit.GetName(); return oss; }