I have 4 numbers:b1 b2 b3 b4 (b1 is MSB, b4 is LSB) and I want to combine them into one number of 32-bit as b1b2b3b4;tried the following but didn't work (i guess overflow):
res = (unsigned long)((b4 & 0xFF) | (((unsigned long)(b3<<8)) & 0xFF00));
res = (unsigned long)(res | (((unsigned long)(b2<<16)) & 0xFF0000));
res = (unsigned long)(res |(((unsigned long)(b1<<24)) & 0xFF000000));
b1 = 86; b2 = 120; b3 = 154; b4 = 188;
result should be : 1450744508 in decimal or 56789abc in hex