|
-
March 7th, 2011, 10:55 AM
#1
Break down word into 4 bytes using shift and mask
If I have a word: unsigned int x and I'd like to break it down into four bytes: unsigned char b1, b2, b3, b4, can someone tell me the proper syntax on how to do this. I know you have to shift and then mask, but am not sure how to go about doing it from a code perspective.
Code:
b1 = x //&& mask all but the lowest order byte
b2 = x >> 8 //&& mask all but the lowest order byte
b3 = x >> 16 //&& mask all but the lowest order byte
b4 = x >> 24//&& mask all but the lowest order byte
??
Thanks.
Last edited by CoDEFRo; March 7th, 2011 at 11:02 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|