On Monday 11 January 2010 03:38:53 Larry Finger wrote: > Yes, my fault. The specs are now corrected so that these statements are > > ((s8)((s[1] >> 8) & 0x3F) << 2) >> 2 > > I think that is right. No it is not. You need to do this: (s8)(((s[1] >> 8) & 0x3F) << 2) >> 2 Alternatively add another pair of parenthesis to make it clearer: ((s8)(((s[1] >> 8) & 0x3F) << 2)) >> 2 This basically shifts left unsigned and then shifts right _arithmetically_. In your example, the compiler will optimize both shifts away (it may actually also optimize the shifts in my case, but the sign extension will persist. Just try it and you'll see: mb@homer:~$ cat t.c #include <stdio.h> #include <stdint.h> int main() { int8_t s0; int8_t s1; uint8_t u; u = 0x3D; s0 = ((int8_t)(u & 0x3F) << 2) >> 2; s1 = ((int8_t)((u & 0x3F) << 2)) >> 2; printf("%d %d\n", s0, s1); } mb@homer:~$ gcc -o t t.c mb@homer:~$ ./t 61 -3 -- Greetings, Michael. -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html