I'm aware of the two complement representation. I was wondering what are the specifics differences, in terms of implementation between int
and unsigned int
. I would than say that
- Comparison is different (the sign bit will change how the comparison is performed).
- Multiplication is different (I take the modulus, multiply such modules and complement the result based on the sign of both operands).
- Division is different (same reason of multiplication).
- Addition and subtraction look the same
Are there any other differences that maybe I'm not aware of?
x - y
would be the same for both signed and unsigned representation, the interpreted result would be different (underflow in int representation, and negative number in signed representation but the operation would be exactly the same). – user8469759 Jan 23 '17 at 10:59