Fix SB function when using sizes greater than 32 bits

This commit is contained in:
Jonathan G Rennison
2022-01-13 01:06:31 +00:00
parent 9e1a78c86e
commit 29521ef883

View File

@@ -60,7 +60,8 @@ template <typename T, typename U>
static inline T SB(T &x, const uint8 s, const uint8 n, const U d)
{
x &= (T)(~((((T)1U << n) - 1) << s));
x |= (T)(d << s);
typename std::make_unsigned<T>::type td = d;
x |= (T)(td << s);
return x;
}