Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

Like this presentation? Why not share!

- 1s and 2s complement by Then Murugeshwari 63064 views
- 1's and 2's complement by Shiraz Azeem 933 views
- Two’s complement by mayannpolisticoLNU 13070 views
- 2s complement arithmetic by Sanjay Saluth 1824 views
- Binary Operation Boolean Logic by Fintine 605 views
- Decimal to binary number by guestd8696a 1896 views

735 views

Published on

1's and 2's complements

No Downloads

Total views

735

On SlideShare

0

From Embeds

0

Number of Embeds

14

Shares

0

Downloads

43

Comments

0

Likes

1

No embeds

No notes for slide

- 1. One’s and Two’s Complement Numbers and Arithmetic Operations 1 Digital electronics 13IDP14
- 2. 2 OutlineOutline Number of binary digits (bits) used in computers for arithmetic operations Positive and negative number representation using bits 1’s complement and 2’s complement Arithmetic operations in 2’s complement Carry and overflow concepts See module 2a notes for more examples
- 3. Bits Used in Computers for Numbers and Implications 4, 8, 16, 32, 64 Using 4 bits we can only represent 24 = 16 numbers -8, -7, -6, -5, …-1, 0, 1, … 7 Using 8 bits we can only represent 28 = 256 numbers -128, -127, …-1, 0, 1, … 127 Since we can represent only a fixed number of positive and negative numbers, we may get wrong results when we compute arithmetic operations We must determine when the results are wrong
- 4. One’s and Two’s Complement 0111 0110 0101 0100 0011 0010 0001 0000 1111 1110 1101 1100 1011 1010 1001 1000 +7 +6 +5 +4 +3 +2 +1 +0 -0 -1 -2 -3 -4 -5 -6 -7 Cryptography -Part -I 4 0111 0110 0101 0100 0011 0010 0001 0000 1111 1110 1101 1100 1011 1010 1001 1000 +7 +6 +5 +4 +3 +2 +1 +0 -1 -2 -3 -4 -5 -6 -7 -8 One’s Complement Two’s Complement
- 5. Two’s Complement Number Representation and Value (1) MSB represents negative number with a value. Example: 8-bit number say 1101 0011 Value in decimal = -1*27 + 1*26 + 0*25 + 1*24 + 0*23 +0*22 + 1*21 + 1 =-128 +64+0+16+0+0+2+1 =-128+83 =-45 Cryptography -Part -I 5
- 6. Two’s Complement Number Representation and Value (2) Example: 1111 1111 Decimal Value = -1*27 + 1*26 + 1*25 + 1*24 + 1*23 +1*22 + 1*21 + 1 = -128+64+32+16+8+4+2+1 =-128+127 = -1 Example: 1000 0000 Value = -128 Example: 0111 1111 Value = 127 Cryptography -Part -I 6
- 7. Finding a Negative of a number Assume 1’s complement Number 8-bit: 0000 1111; value =15 Given 15 determine -15 Change all 0 to 1 and 1 to zero Result: 1111 0000 = -127+64+32+16 =-127+112 = -15 Assume 2’s complement Number 8-bit: 0000 1111; value =15 Given 15 determine -15 Change all 0 to 1 and 1 to zero then add 1 Result: 1111 0001 = -128+64+32+16+1 =-128+113 = -15 7
- 8. Arithmetic Operations in Two’s Complement (1) Example:Find 7 – 5 assuming 4-bit numbers 7 = 0111 ; -5 =1011 in 2’s complement 0111 1011 ----- 10010 Carry in MSB 1, Carry out in MSB 1 Result ok value 2
- 9. Arithmetic Operations in Two’s Complement (2) Example:Find 7 + 5 assuming 4-bit numbers 7 = 0111 ; 5 =0101 in 2’s complement 0111 0101 ----- 1100 Carry in MSB 1, Carry out in MSB 0 Result wrong; value -4. We can not represent real value 12. This is overflow. 9
- 10. Arithmetic Operations in Two’s Complement (2) Example:Find 7 + 5 assuming 4-bit numbers 7 = 0111 ; 5 =0101 in 2’s complement 0111 0101 ----- 1100 Carry in MSB 1, Carry out in MSB 0 Result wrong; value -4. We can not represent real value 12. This is overflow. 9

No public clipboards found for this slide

×
### Save the most important slides with Clipping

Clipping is a handy way to collect and organize the most important slides from a presentation. You can keep your great finds in clipboards organized around topics.

Be the first to comment