1 / 22

Chapter 6

Chapter 6. Binary Arithmetic. Addition. Binary Addition. Binary addition is very simple. This is best shown in an example of adding two binary numbers…. 1. 1. 1. 1. 1. 1. carries. 1 1 1 1 0 1 + 1 0 1 1 1 ---------------------. 1. 0. 1. 0. 1. 0. 0.

djohns
Download Presentation

Chapter 6

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 6 Binary Arithmetic

  2. Addition

  3. Binary Addition • Binary addition is very simple. • This is best shown in an example of adding two binary numbers… 1 1 1 1 1 1 carries 1 1 1 1 0 1 + 1 0 1 1 1 --------------------- 1 0 1 0 1 0 0

  4. Binary addition example worked out • Some terms are given here • Exercise: what are these numbers equivalent to in decimal? The initial carry in is implicitly 0 1 1 1 0 (Carries) 1 0 1 1 (Augend) + 1 1 1 0 (Addend) 1 1 0 0 1 (Sum) most significant bit (MSB) least significant bit (LSB)

  5. Subtraction

  6. 1 10 0 10 10 0 0 10 1 0 0 1 1 0 1 - 1 0 1 1 1 ------------------------ 1 1 0 1 1 0 borrows Binary Subtraction • We can also perform subtraction (with borrows in place of carries). • Let’s subtract (10111)2 from (1001101)2…

  7. Ignore carry Negative Numbers Subtract by adding 73 -35 38 73 +65 138 10’s complement

  8. Two’s Complement Shortcuts • Algorithm – Simply complement each bit and then add 1 to the result. • Finding the 2’s complement of (01100101)2 and of its 2’s complement… N = 01100101 [N] = 10011011 10011010 01100100 + 1 + 1 --------------- --------------- 10011011 01100101

  9. Negative Numbers Subtract by adding 73 -35 38 0 1 0 0 1 0 0 1 1 1 0 1 1 1 0 1 0 0 1 0 0 1 1 0 • 01001001 • 35 00100011 • 2’s comp 11011100 flip • +1 • ----------- • -35 11011101

  10. Signed Numbers 4-bit: 8H = -8 to 7H = +7 1000 to 0111 8-bit: 80H = -128 to 7F = +127 16-bit: 8000H = -32,768 to 7FFFH = +32,767 32-bit: 80000000H = -2,147,483,648 to 7FFFFFFFH = +2,147,483,647

  11. Questions What is the two’s complement of 00101100? What hex number represents the decimal number -40?

  12. Multiplication

  13. Binary Multiplication • Binary multiplication is much the same as decimal multiplication, except that the multiplication operations are much simpler… 1 0 1 1 1 X 1 0 1 0 ----------------------- 0 0 0 0 0 1 0 1 1 1 0 0 0 0 0 1 0 1 1 1 ----------------------- 1 1 1 0 0 1 1 0

  14. ASCII CODES

  15. ASCII • The most commonly used code for representing letters, numerals and punctuation characters (alphanumeric data) • Each character is represented with a 7-bit string; for example: • ‘3’ = 00110011 (hex 33) • ‘ ’ = 00100000 (hex 20) • An 8-bit extension of ASCII has also been defined

  16. ASCII Code • American Standard Code for Information Interchange • ASCII is a 7-bit code, frequently used with an 8th bit for error detection (more about that in a bit).

  17. ASCII Properties Q1: What is relationship between a decimal digit (0, 1, …) and its ASCII code?

  18. ASCII Properties (2) Q2: What is the difference between an upper-case letter (A, B, …) and its lower-case equivalent (a, b, …)?

  19. BCD

  20. Binary Coded Decimal • Binary coded decimal (BCD) represents each decimal digit with four bits • Ex. 0011 0010 1001 = 329BCD • This is NOT the same as 0011001010012 • Why do this? Because people think in decimal. 3 2 9

  21. Putting It All Together • BCD not very efficient • Used in early computers (40s, 50s) • Used to encode numbers for seven-segment displays. • Easier to read?

More Related