Merge remote-tracking branch 'origin/detached' into HEAD

This commit is contained in:
2025-10-23 14:58:54 -04:00

View File

@@ -3,8 +3,6 @@
//
#pragma once
#include <cmath>
#include <cstdint>
#include <format>
#include <string>
@@ -15,9 +13,9 @@ std::string toHuman( std::size_t size )
{
constexpr std::size_t mod { 1024 };
if ( size < mod ) return std::format( "{}B", size );
if ( size < std::pow( mod, 2ul ) ) return std::format( "{}KiB", static_cast< int >( size / mod ) );
if ( size < std::pow( mod, 3ul ) ) return std::format( "{}MiB", static_cast< int >( size / std::pow( mod, 2 ) ) );
if ( size < std::pow( mod, 4ul ) ) return std::format( "{}GiB", static_cast< int >( size / std::pow( mod, 3 ) ) );
return std::format( "{}TiB", static_cast< int >( size / std::pow( mod, 4 ) ) );
if ( size < mod * mod ) return std::format( "{}KiB", static_cast< int >( size / mod ) );
if ( size < mod * mod * mod ) return std::format( "{}MiB", static_cast< int >( size / ( mod * mod ) ) );
if ( size < mod * mod * mod * mod ) return std::format( "{}GiB", static_cast< int >( size / ( mod * mod * mod ) ) );
return std::format( "{}TiB", static_cast< int >( size / ( mod * mod * mod * mod ) ) );
}
} // namespace fgl::size