diff --git a/include/fgl/size.hpp b/include/fgl/size.hpp index af18357..82634ec 100644 --- a/include/fgl/size.hpp +++ b/include/fgl/size.hpp @@ -3,8 +3,6 @@ // #pragma once -#include -#include #include #include @@ -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 \ No newline at end of file