F451 Understanding Twos Complement and Sign & Magnitude:

A PDF I made to explain Two's Complement and Sign & Magnitude.

HideShow resource information
• Created by: Jonathan
• Created on: 23-05-12 14:08

First 243 words of the document:

Understanding Two's Complement and Sign & Magnitude:
You need to know what these are so that you can perform equations with binary numbers.
MSB = Most Significant Bit, this is the bit which determines whether it is +ve or -ve
Two's Complement is a way of displaying negative numbers:
-128 64 32 16 8 4 2 1
+117 does not need to use the MSB (-128) so it is written as 01110101
However,
-117 does need to use the MSB so it is written as 10001011
-117 = -128 + 11
-128 + (8+2+1) = -117
One way of calculating the two's compliment value of a negative number is shown above, however
there is a nice algorithm which most people find easier:
- Work out the binary value of the positive number (make sure you write down the whole
- Flip all the digits i.e. 0 for 1 and 1 for 0
Example: -117
Stage 1, 01110101
Stage 2, 10001010
Stage 3, 10001011
This is the same value we got for the other method
Sign and Magnitude
The MSB is 0 for a +ve and 1 for a ­ve, this replaces the first 0/1 which was previously 128
Therefore:
+117 = 01110101 and -117 = 11110101
Only 7 of the bits of data actually store this size of the integer. The 8th is reserved for +ve or ­ve
#NOTE: You will be told which form the binary is in in the exam.#