Hi folks -
I'm writing some code for a checksum algorithm and I need to reverse the
order of bits in an unsigned char array, in 4-bit chunks (half byte, or
nibble).
Example.. the array contains BYTE data:
0001 0110, 0000 0010, 1000 0000
0x16, 0x02, 0x80
Each nibble gets reversed:
1000 0110, 0000 0100, 0001 0000
0x86, 0x04, 0x10
Each nibble will then be added and the results become a checksum nibble.
I can do this brute force, one bit at a time, but I'm hoping someone out
there will recognize a possible elegant solution. There will always be 5
bytes (40 bits, 10 nibbles) to deal with.
Any ideas?
Thanks.