Twos Complement Twos Complement n A system used
- Slides: 22
Two’s Complement
Two’s Complement n A system used to represent a negative number in binary Positive numbers start with a 0 n Negative numbers start with a 1 n
On a cars Mileometer if you went backwards this would happen: 9 0 9 0 6 0 1 2 3 9 8 7
Two’s Complement is like a Speedometer……. 128 64 32 16 8 0 0 Positive MSB (Most Significant Bit) indicated by 0 0 4 2 1 0 1 1 = 3
Two’s Complement is like a Speedometer……. 128 64 32 16 8 0 0 0 Positive MSB indicated by 0 0 0 4 2 1 0 = 2
Two’s Complement is like a Speedometer……. 128 64 32 16 8 0 0 0 Positive MSB indicated by 0 0 0 4 2 1 0 0 1 = 1
Two’s Complement is like a Speedometer……. 128 64 32 16 8 0 0 0 Positive MSB indicated by 0 0 0 4 2 1 0 0 0 = 0
Two’s Complement is like a Speedometer……. -128 64 32 16 8 1 1 1 Negative MSB indicated by 1 1 1 4 2 1 1 = -1
Two’s Complement is like a Speedometer……. -128 64 32 16 8 1 1 1 Negative MSB indicated by 1 1 1 4 2 1 1 1 0 = -2
Two’s Complement is like a Speedometer……. -128 64 32 16 8 1 1 1 Negative MSB indicated by 1 1 1 4 2 1 1 0 1 = -3
How can you convert a negative two’s complement number to denary? Example: Convert two’s complement 10010110 -128 1 64 0 32 0 16 1 This would be: -128 + 16 + 4 + 2 = -106 8 0 4 1 2 1 1 0
Example 2 Convert two’s complement 11011011 -128 1 64 1 32 16 0 1 8 4 1 0 This would be: -128 + 64 + 16 + 8 + 2 + 1 = -37 2 1 1 1
Activity Convert the following numbers to denary: 1. 2. 3. 4. Two’s complement 0011 Two’s complement 1100 Two’s complement 10111101 Binary (no +- MSB at the start) 11110101
How can you convert a negative denary number into two’s complement? Step 1 pretend negative denary number is positive and convert it into binary e. g. -52 becomes 52 128 0 64 0 32 16 1 1 8 4 0 1 2 0 1 0
How can you convert a negative denary number into two’s complement? Step 2 Starting from the right, leave all digits alone, up to and including the first 1, then change all the other digits around (0 to 1) or (1 to 0) 126 64 32 16 8 4 2 1 0 0 1 1 0 0
Alternative Method: Create positive binary number as before: 128 64 32 16 8 0 0 1 1 0 1 Next change all 1’s and 0’s around: 128 64 32 16 8 1 1 0 0 1 0 Then add 1 to the number: 128 64 32 16 8 1 1 0 0 1 0 + 0 0 0 = 1 1 0 0 1 1 4 0 2 0 1 4 1 2 1 1 4 1 0 0 2 1 1 0 1
Addition in Binary 128 64 32 16 8 4 2 1 0 0 1 1 0 1 +0 0 1 1 1 0 1 1 Denary 77 59 1 0 0 0 1 1 1 136
Addition Exercise Add 47 to 159 in binary n Add 12 to 47 in binary n
Subtraction in Binary n Rather than subtracting, convert the number that is to be subtracted into a negative number then add them together as before
Subtraction in Binary e. g. 15 -12 12 = 00001100 -12 = 11110100 15 = 00001111 + 11110100 (1) 00000011 The carry of 1 is ignored
Subtraction Exercises 1. 2. Subtract 23 from 123 in binary Subtract 14 from 32 in binary
Rules: Positive numbers have a 0 as the MSB n Negative numbers have a 1 as the MSB n Even numbers have 0 as the LSB (Least Significant Bit) n Odd numbers have 1 as the LSB n -1 is always represented by a 1 in every bit regardless of number of bits n
- 2s complement
- Two complement overflow
- Creative curriculum intentional teaching cards
- Problem solving using venn diagram
- The 2's complement of 15 is
- Salmonella life cycle
- Complement system
- In a premix burner used in fes the fuel used is
- In a premix burner used in fes the fuel used is
- Earth closed system
- Respiratory digestive and circulatory system
- Number system
- Predominant energy system
- All appliances must be equipped with a service aperture
- Discipline of classifying and naming organisms
- System dependent recovery equipment cannot be used when
- Discuss the role of computers in preclinical development
- List the auxiliary system used in substation
- Most commonly used system
- Andres bonifacio pen name
- Appurtenances used in water distribution system
- What are binary numbers
- Vhdl 2's complement