All,
I have been practicing coding problems online. Currently I am working on a problem statement Problems where we need to convert Big Endian <-> little endian.
I think this can also help:
int littleToBig(int i) { int b0,b1,b2,b3; b0 = (i&0x000000ff)>>0; b1 = (i&0x0000ff00)>>8; b2 = (i&0x00ff0000)>>16; b3 = (i&0xff000000)>>24; return ((b0<<24)|(b1<<16)|(b2<<8)|(b3<<0)); }