01
Nov
Swap Bits in a Byte without using any extra variable
Related Blog Items
- Bit swapping - Style II
- Bit swapping - Style I
- Bit Twiddling/Manipulation Hacks
- Swapping variables without additional space
- Advanced Test in C: The 0x0A Best Questions for C Programmers
SwapBitsInByte(unsigned char n)
{
n = (n & 0xF0) >> 4 | (n & 0x0F) < < 4;
n = (n & 0xCC) >> 2 | (n & 0×33) < < 2;
n = (n & 0xAA) >> 1 | (n & 0×55) << 1;
return n;
}
download this code
Popularity: 13%
You need to log on to convert this article into PDF
Related Blog Items - Bit swapping - Style II
- Bit swapping - Style I
- Bit Twiddling/Manipulation Hacks
- Swapping variables without additional space
- Advanced Test in C: The 0x0A Best Questions for C Programmers
Related Blog Items
- Bit swapping - Style II
- Bit swapping - Style I
- Bit Twiddling/Manipulation Hacks
- Swapping variables without additional space
- Advanced Test in C: The 0x0A Best Questions for C Programmers
No Comments
No comments yet.