Reverse the bit of an interger (assume it has 32-bit)
Page 1 of 1
Reverse the bit of an interger (assume it has 32-bit)
1____unsigned int reverse_bit(unsigned int x) {
2__________x = (x & 0x0000ffff) << 16 | (x & 0xffff0000) >> 16;
3__________x = (x & 0x00ff00ff) << 8 | (x & 0xff00ff00) >> 8;
4__________x = (x & 0x0f0f0f0f) << 4 | (x & 0xf0f0f0f0) >> 4;
5__________x = (x & 0x33333333) << 2 | (x & 0xcccccccc) >> 2;
6__________x = (x & 0x55555555) << 1 | (x & 0xaaaaaaaa) >> 1;
7____}
2__________x = (x & 0x0000ffff) << 16 | (x & 0xffff0000) >> 16;
3__________x = (x & 0x00ff00ff) << 8 | (x & 0xff00ff00) >> 8;
4__________x = (x & 0x0f0f0f0f) << 4 | (x & 0xf0f0f0f0) >> 4;
5__________x = (x & 0x33333333) << 2 | (x & 0xcccccccc) >> 2;
6__________x = (x & 0x55555555) << 1 | (x & 0xaaaaaaaa) >> 1;
7____}
viterbi- Posts : 32
Join date : 2011-09-03
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|