We are writing an emulator where we need sign propagating right shift. The emulated system uses 2\'s complement numbers.
I read that the >> operat
>>
This function will work no matter the machine definition of 'int', by shifting the absolute value (i.e. without the sign) and then adding the sign:
int shift(int value, int count) { return ((value > 0) - (value < 0)) * (abs(value) >> count); }