5 3
play

5 + 3 ----- Try these, in decimal 5 + 3 ----- 8 Try these, - PDF document

Addition / Subtraction ICS3U Mr. Emmell Try these, in decimal 5 + 3 ----- Try these, in decimal 5 + 3 ----- 8 Try these, in decimal 8 + 4 ----- Try these, in decimal 8 + 4 ----- 1 2 How did you do that? When one column


  1. Addition / Subtraction ICS3U Mr. Emmell Try these, in decimal 5 + 3 -----

  2. Try these, in decimal 5 + 3 ----- 8 Try these, in decimal 8 + 4 -----

  3. Try these, in decimal 8 + 4 ----- 1 2 How did you do that? When one column overflowed…. It incremented the next column

  4. How did you know it overflowed? When one column… tried to have a higher value than our number system allowed! Then you - Subtracted ten - Wrote the remainder - Added the carry Try these, in octal 2 8 + 4 8 -------

  5. Try these, in octal 2 8 + 4 8 ------- 6 8 Try these, in octal 5 8 + 5 8 -------

  6. Try these, in octal 5 + 5 = 10!!!! That’s too 5 8 much This is base 8 + 5 8 so… ------- 10 – 8 = 2 Try these, in octal 5 8 + 5 8 ------- 1 2 8

  7. Try these, in octal 1 5 8 + 5 8 ------- Try these, in octal 1 5 8 + 5 8 ------- 2 2 8

  8. Try these, in octal 3 5 8 + 4 6 8 ------- Try these, in octal 3 5 8 + 4 6 8 ------- 1 0 3 8

  9. Hexadecimal works the same way! 3 16 + 6 16 ------- Hexadecimal works the same way! 3 16 + 6 16 ------- 9 16

  10. Hexadecimal works the same way! 7 16 + 6 16 ------- Hexadecimal works the same way! 7 16 + 6 16 ------- D 16

  11. Hexadecimal works the same way! B 9 16 + A 16 ---------- Hexadecimal works the same way! B 9 16 Remember! In decimal, + A 16 this is: 9 ------- + 10 = 19

  12. Hexadecimal works the same way! B 9 16 + A 16 ---------- C 3 16 Hexadecimal works the same way! 2 6 16 + 7 E 16 -------

  13. Hexadecimal works the same way! 2 6 16 + 7 E 16 ------- A 4 16 Don’t forget binary too 1 0 0 1 2 + 1 0 1 1 2 ------------

  14. Don’t forget binary too 1 0 0 1 2 + 1 0 1 1 2 ------------ 1 0 1 0 0 2 Now… how about subtraction? Good news! We can’t… Not really. We need to learn about complements first

  15. So instead, we add the complement. Consider a 12 hour clock. If it is 11:00 now, then three hours later it will be 2:00 11 + 3 = 14 ≡ 2 (mod 12) 2 o’clock So instead, we add the complement. Similarly, if it is 1:00, then 4 hours ago it was 9 since 1 − 4 = −3 ≡ 9 (mod 12) 9 o’clock

  16. So instead, we add the complement. Notice that subtracting 4 hours on the clock is the same as adding 8 hours (12 – 4). In particular, we could have computed it as follows: 1 − 4 ≡ 1 + 8 = 9 (mod 12) Binary numbers work the same way Use an 8-bit number as an example Those numbers range from 0-255 If we have 255 and add one, then we get zero because it ‘cycles back’.

  17. So….? How do we find the complement for a number in binary? We know that 200 – 50 is the same as 200 + (255-50) (Because we roll over after 255!) HOW TO FIND “TWO’s COMPLEMENT” ⚫ Define how many bits you are using! 8-bit? ⚫ Always need to have leading zeroes. ⚫ Invert all the bits ⚫ Add one ⚫ BOOM – Two’s complement. Add normally using binary addition.

  18. Example 100 – 58 = 42 Now for this operation, we are really saying: 100 + (-58) = 42 Let’s convert to binary Example 100 2 100 = 01100100 2 50 0 2 25 0 2 Remember! 8-bits 12 1 2 6 0 2 3 0 2 What about -58? 1 1 2 0 1

  19. Example – Start with 58 58 2 58 = 00111010 2 29 0 2 14 1 2 Remember! 8-bits 7 0 2 3 1 2 1 1 2 What about -58? 0 1 Example 00111010 2 //58 11000101 2 //FLIP +1 //Add one 11000110 -58 = 11000110 2

  20. Now we do the ‘addition’ 0 1 1 0 0 1 0 0 2 1 1 0 0 0 1 1 0 2 Now we do the ‘addition’ 0 1 1 0 0 1 0 0 2 1 1 0 0 0 1 1 0 2 1 0 0 1 0 1 0 1 0 2 If there is a leading one, we drop it (remember! 8-bits) Answer = 00101010 2 (42 !)

  21. Note: Rather than having our numbers go from 0 to 255 around a clock, we have them go from −128 to 127

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