View Single Post
Posts: 2,154 | Thanked: 8,464 times | Joined on May 2010
#120
Originally Posted by Fabry View Post
It's not the same.

(4*C>>2) = ((C<<2)>>2) = clear two most significative bits

For example suppose C as byte (unsigned):

If C = 46 (0010 1110) then (4*C>>2) = 46 (0010 1110) also, but if C = 114 (0111 0010) then (4*C>>2) = 50 (0011 0010)
No, It is same because first is multiply and then is byteshift. Try this:

Code:
printf("%#x %#x\n", 4*114 >> 2, 114);
printf("%#x %#x\n", 4*46 >> 2, 46);
output is:

Code:
0x72 0x72
0x2e 0x2e