The problem is that the type of 0xFFE00000
is uint
(because it's greater than 0x7fffffff
), and there's no &(int, uint)
operator, so both sides are promoted to long
.
The fix is simple: just shift and then mask:
value = (lineIntData >> 21) & 0x7ff;
Now everything stays an int
throughout.
By the way, I personally always use brackets when shifting and masking. It means I don't need to remember the precedence rules for those operators. While I remember precedence for some operators, this is one case where I'd rather just use brackets.