HI, I'm currently working on a project where I need to split an unsigned 16bit int into bytes the code I have written is:
Code:
msg[AXIS_HI]=value>>8;
msg[AXIS_LO]=(uint8)value;
The software I'm working on provides various macros for byte manipulation there is one macro that splits 16 bit ints;
Code:
#define HI_UINT16(a) (((a) >> 8) & 0xFF)
#define LO_UINT16(a) ((a) & 0xFF)
I'm a C novice so I'm not sure what the purpose of the and operation is I understand what it does I'm just not sure why it's necessary.