mirror of
https://github.com/g-truc/glm.git
synced 2024-11-10 04:31:47 +00:00
Merge pull request #17 from muep/fix_msb
Progress on fixing FindMSB implementation. Negative values and zeros remains to be done.
This commit is contained in:
commit
d6bbf90670
@ -543,7 +543,14 @@ namespace glm
|
||||
genIUType const & Value
|
||||
)
|
||||
{
|
||||
return __builtin_clz(Value);
|
||||
/**
|
||||
* clz returns the number or trailing 0-bits; see
|
||||
* http://gcc.gnu.org/onlinedocs/gcc-4.7.1/gcc/Other-Builtins.html
|
||||
*
|
||||
* NoteBecause __builtin_clz only works for unsigned ints, this
|
||||
* implementation will not work for 64-bit integers.
|
||||
*/
|
||||
return 31 - __builtin_clz(Value);
|
||||
}
|
||||
|
||||
#else
|
||||
|
@ -60,10 +60,8 @@ namespace _detail
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T operator() (T const & Value) const
|
||||
{
|
||||
#if(GLM_COMPILER & GLM_COMPILER_VC)
|
||||
#if(GLM_COMPILER & (GLM_COMPILER_VC | GLM_COMPILER_GCC))
|
||||
return Value <= T(1) ? T(0) : T(32) - nlz(Value - T(1));
|
||||
#elif(GLM_COMPILER & GLM_COMPILER_GCC)
|
||||
return Value <= T(1) ? T(0) : nlz(Value - T(1)) + 1;
|
||||
#else
|
||||
return T(32) - nlz(Value - T(1));
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user