CS 120 Lecture Notes - Lecture 3: Negative Number, Signed Number Representations
Document Summary
Signed magnitude: reserving the first bit to represent positivity or negativity. Representing 5 in signed binary, the positive number would be 0101, and the negative number 5 would be 1101. One"s compliment: switching all the numbers to the other number to represent negativity. Given that 5 is 0101 in unsigned binary, -5 is 1010 in one"s compliment signed binary. This leads to the problem of -0: 0101 + 1010 = 1111, 5 + (-5) = 0, but the equation in one"s compliment signed binary gives the number. Two"s compliment: this has a similar process to one"s compliment, but after flipping the bits, add 1 to the number. This gets rid of the -0 problem. This also has signed magnitude, because the first number represents if the number is positive: 1 is negative, so the number needs to be converted back to its positive version to obtain the number.