void SpeedCommand(signed short val) { unsigned char b1,b2; b1 = val & 0x00FF; b2 = val >> 8; printf("data: %x\n",val); printf("byte1: %x byte2: %x\n",b1,b2); } Called like this: short test = 0x4080; SpeedCommand(test); Gives this: data: 4080 byte1: 80 byte2: 40 Shouldnt it be the other way around?