May 20, 2019 #1 S sushl Junior Member level 2 Joined Aug 22, 2018 Messages 24 Helped 0 Reputation 0 Reaction score 0 Trophy points 1 Activity points 238 Hi , can anyone explain me the logic of this IDIOM (((x&0xff)<<8)¦((x&0xff00)>>8)¦((x&0xff000000)>>8)¦((x&0x00ff0000)<<8));
Hi , can anyone explain me the logic of this IDIOM (((x&0xff)<<8)¦((x&0xff00)>>8)¦((x&0xff000000)>>8)¦((x&0x00ff0000)<<8));
May 20, 2019 #2 kripacharya Banned Joined Dec 28, 2012 Messages 1,204 Helped 182 Reputation 360 Reaction score 175 Trophy points 1,343 Location New Delhi Activity points 0 It swaps byte 0<-->1, and byte 2<-->3. The '&0ff' is basically extracting specific sets of 8 bits at a time. Think A and 011111111 Next, the '<<' or '>>' operators then shift left or right by 8 bits. And of course the '|' or operator combines them back again. Quite simple really
It swaps byte 0<-->1, and byte 2<-->3. The '&0ff' is basically extracting specific sets of 8 bits at a time. Think A and 011111111 Next, the '<<' or '>>' operators then shift left or right by 8 bits. And of course the '|' or operator combines them back again. Quite simple really