Improved ***PowerOfTwo

This commit is contained in:
Christophe Riccio 2016-04-29 17:31:36 +02:00
parent 68ec048b70
commit 872aa9d8ec

View File

@ -174,7 +174,7 @@ namespace isPowerOfTwo
}
}//isPowerOfTwo
namespace ceilPowerOfTwo
namespace ceilPowerOfTwo_advanced
{
template <typename genIUType>
GLM_FUNC_QUALIFIER genIUType highestBitValue(genIUType Value)
@ -292,7 +292,7 @@ namespace ceilPowerOfTwo
return Error;
}
}//namespace ceilPowerOfTwo
}//namespace ceilPowerOfTwo_advanced
namespace roundPowerOfTwo
{
@ -341,6 +341,25 @@ namespace floorPowerOfTwo
}
}//namespace floorPowerOfTwo
namespace ceilPowerOfTwo
{
int test()
{
int Error = 0;
glm::uint32 const A = glm::ceilPowerOfTwo(7u);
Error += A == 8u ? 0 : 1;
glm::uint32 const B = glm::ceilPowerOfTwo(15u);
Error += B == 16u ? 0 : 1;
glm::uint32 const C = glm::ceilPowerOfTwo(31u);
Error += C == 32u ? 0 : 1;
return Error;
}
}//namespace ceilPowerOfTwo
namespace floorMultiple
{
template <typename genType>
@ -426,9 +445,10 @@ int main()
int Error(0);
Error += isPowerOfTwo::test();
Error += ceilPowerOfTwo::test();
Error += floorPowerOfTwo::test();
Error += roundPowerOfTwo::test();
Error += ceilPowerOfTwo::test();
Error += ceilPowerOfTwo_advanced::test();
# ifdef NDEBUG
Error += ceilPowerOfTwo::perf();