diff --git a/glm/core/func_integer.inl b/glm/core/func_integer.inl index c5e6fe25..6be3c87f 100644 --- a/glm/core/func_integer.inl +++ b/glm/core/func_integer.inl @@ -394,13 +394,14 @@ namespace glm template inline genIUType bitfieldReverse(genIUType const & Value) { - GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'bitfieldReverse' only accept integer values"); + GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'bitRevert' only accept integer values"); - genIUType Result = 0; - for(std::size_t i = 0; i < sizeof(genIUType) * std::size_t(8); ++i) - if(Value & (1 << i)) - Result |= (genIUType(1) << (sizeof(genIUType) * std::size_t(8)) - genIUType(1) - i); - return Result; + genIUType Out = 0; + std::size_t BitSize = sizeof(genIUType) * 8; + for(std::size_t i = 0; i < BitSize; ++i) + if(In & (genIUType(1) << i)) + Out |= genIUType(1) << (BitSize - 1 - i); + return Out; } template