> Hi, I need to split up a byte value into two nybbles, I understand bit
> shifting is the ideal method to perform this task.
>
> Could someone explain how to do this please.
>
> TIA
Well, a nibble is 4 bits, and a byte is 8 bits.
You need to mask part of the byte using binary and (&). 00001111 in
binary = 15 dec and 0xF hex.
lowNib = myByte & 0xF;
Then you need to make the high nibble in myByte the low nibble:
highNib = (myByte >> 4) & 0xF;
Hope this explains it. Good luck,
Daniel.
mikew01 - 27 Mar 2007 09:02 GMT
Thanks for your help.
> Well, a nibble is 4 bits, and a byte is 8 bits.
>
[quoted text clipped - 9 lines]
> Hope this explains it. Good luck,
> Daniel.