cs 230 introduction to computers and
play

CS 230 Introduction to Computers and Computer Systems Lecture 3 - PowerPoint PPT Presentation

CS 230 Introduction to Computers and Computer Systems Lecture 3 Binary Arithmetic and Twos Complement CS 230 - Spring 2020 1-1 Binary Addition Same as regular addition Add digits right to left least significant bit (LSB)


  1. CS 230 – Introduction to Computers and Computer Systems Lecture 3 – Binary Arithmetic and Two’s Complement CS 230 - Spring 2020 1-1

  2. Binary Addition  Same as regular addition  Add digits right to left  least significant bit (LSB) to most significant bit (MSB)  carry CS 230 - Spring 2020 1-2

  3. CS 230 - Spring 2020 1-3

  4. CS 230 - Spring 2020 1-4

  5. CS 230 - Spring 2020 1-5

  6. CS 230 - Spring 2020 1-6

  7. CS 230 - Spring 2020 1-7

  8. CS 230 - Spring 2020 1-8

  9. CS 230 - Spring 2020 1-9

  10. CS 230 - Spring 2020 1-10

  11. CS 230 - Spring 2020 1-11

  12. CS 230 - Spring 2020 1-12

  13. CS 230 - Spring 2020 1-13

  14. CS 230 - Spring 2020 1-14

  15. CS 230 - Spring 2020 1-15

  16. CS 230 - Spring 2020 1-16

  17. CS 230 - Spring 2020 1-17

  18. CS 230 - Spring 2020 1-18

  19. CS 230 - Spring 2020 1-19

  20. CS 230 - Spring 2020 1-20

  21. CS 230 - Spring 2020 1-21

  22. CS 230 - Spring 2020 1-22

  23. Binary Multiplication  Same as regular multiplication  Multiply bits of lower term by upper term  LSB to MSB  Add zeros for each bit multiplied so far  Will always be zeros or copy of upper term  Add copies together to get product CS 230 - Spring 2020 1-23

  24. CS 230 - Spring 2020 1-24

  25. CS 230 - Spring 2020 1-25

  26. CS 230 - Spring 2020 1-26

  27. CS 230 - Spring 2020 1-27

  28. CS 230 - Spring 2020 1-28

  29. CS 230 - Spring 2020 1-29

  30. CS 230 - Spring 2020 1-30

  31. CS 230 - Spring 2020 1-31

  32. CS 230 - Spring 2020 1-32

  33. CS 230 - Spring 2020 1-33

  34. CS 230 - Spring 2020 1-34

  35. CS 230 - Spring 2020 1-35

  36. CS 230 - Spring 2020 1-36

  37. CS 230 - Spring 2020 1-37

  38. CS 230 - Spring 2020 1-38

  39. CS 230 - Spring 2020 1-39

  40. CS 230 - Spring 2020 1-40

  41. CS 230 - Spring 2020 1-41

  42. CS 230 - Spring 2020 1-42

  43. CS 230 - Spring 2020 1-43

  44. CS 230 - Spring 2020 1-44

  45. CS 230 - Spring 2020 1-45

  46. CS 230 - Spring 2020 1-46

  47. CS 230 - Spring 2020 1-47

  48. CS 230 - Spring 2020 1-48

  49. CS 230 - Spring 2020 1-49

  50. CS 230 - Spring 2020 1-50

  51. CS 230 - Spring 2020 1-51

  52. CS 230 - Spring 2020 1-52

  53. CS 230 - Spring 2020 1-53

  54. CS 230 - Spring 2020 1-54

  55. CS 230 - Spring 2020 1-55

  56. CS 230 - Spring 2020 1-56

  57. CS 230 - Spring 2020 1-57

  58. CS 230 - Spring 2020 1-58

  59. CS 230 - Spring 2020 1-59

  60. CS 230 - Spring 2020 1-60

  61. CS 230 - Spring 2020 1-61

  62. CS 230 - Spring 2020 1-62

  63. Revisit Binary Addition  We’ve been doing unsigned binary  But, if you are building circuits then you have a limit to the number of bits available to represent values  Fixed width representation has overflow  An n -bit binary number has range  Min: 0  Max: 2 n -1 CS 230 - Spring 2020 1-63

  64. What about negative numbers?  On paper we can draw a negative sign  In a computer we need a bit  What does this bit mean? CS 230 - Spring 2020 1-64

  65. Signed Magnitude (BAD)  Just have MSB be sign bit  If it’s one the number is negative  If it’s zero the number is positive  Problems  Two zeros  Addition doesn’t work  Ex: 4-bit version (1 sign bit, 3 magnitude bits) 0011 + 1001 = 1100  3 + (-1) = -4  CS 230 - Spring 2020 1-65

  66. One’s Complement (BAD)  Negative numbers are inverted positive numbers  Problems  Still two zeros  Addition sort-of works  Have to re-add in the carry out at the end CS 230 - Spring 2020 1-66

  67. Two's Complement (GOOD)  Negative numbers are inverted positive numbers and then add 1  Single zero! n − 1 ...2 n − 1 − 1 − 2  Range:  Addition just works (drop carry out)  Multiplication also works  Have to extend input to 2x the bits CS 230 - Spring 2020 1-67

  68. CS 230 - Spring 2020 1-68

  69. CS 230 - Spring 2020 1-69

  70. CS 230 - Spring 2020 1-70

  71. CS 230 - Spring 2020 1-71

  72. CS 230 - Spring 2020 1-72

  73. CS 230 - Spring 2020 1-73

  74. CS 230 - Spring 2020 1-74

  75. CS 230 - Spring 2020 1-75

  76. CS 230 - Spring 2020 1-76

  77. CS 230 - Spring 2020 1-77

  78. CS 230 - Spring 2020 1-78

  79. CS 230 - Spring 2020 1-79

  80. CS 230 - Spring 2020 1-80

  81. CS 230 - Spring 2020 1-81

  82. CS 230 - Spring 2020 1-82

  83. CS 230 - Spring 2020 1-83

  84. CS 230 - Spring 2020 1-84

  85. CS 230 - Spring 2020 1-85

  86. CS 230 - Spring 2020 1-86

  87. CS 230 - Spring 2020 1-87

  88. CS 230 - Spring 2020 1-88

  89. CS 230 - Spring 2020 1-89

  90. CS 230 - Spring 2020 1-90

  91. CS 230 - Spring 2020 1-91

  92. CS 230 - Spring 2020 1-92

  93. CS 230 - Spring 2020 1-93

  94. CS 230 - Spring 2020 1-94

  95. CS 230 - Spring 2020 1-95

  96. CS 230 - Spring 2020 1-96

  97. CS 230 - Spring 2020 1-97

  98. CS 230 - Spring 2020 1-98

  99. CS 230 - Spring 2020 1-99

  100. CS 230 - Spring 2020 1-100

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend