1 / 41

Algorithms for Integer Arithmetic

Algorithms for Integer Arithmetic. Addition Algorithm. Three Steps to Adding Two Integers. STEP 1. Do they have the same sign ? (both positive or both negative) or Do they have opposite signs ? (one positive and the other negative). Same Signs. STEP 2. Enter the common sign:.

ducan
Télécharger la présentation

Algorithms for Integer Arithmetic

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. Algorithms for Integer Arithmetic Addition Algorithm

  2. Three Steps to Adding Two Integers STEP 1. Do they have the samesign? (both positive or both negative) or Do they have oppositesigns? (one positive and the other negative)

  3. Same Signs STEP 2. Enter the common sign: STEP 3. Now enter the sum of the absolute values: (add the magnitudes)

  4. Opposite Signs STEP 2. Enter the sign of the number having the larger magnitude: STEP 3. Enter the difference of the larger magnitude and the smaller:

  5. Work it out!

  6. Step 1 Same or opposite signs? They have opposite signs.

  7. Step 2 Enter the sign of the number having the larger magnitude: |-34| = 34 > 12 = |12|

  8. Step 3 Subtract the smaller magnitude from the larger and enter the result.

  9. Work it out!

  10. Step 1 Same or opposite signs? They have opposite signs.

  11. Step 2 Enter the sign of the number having the larger magnitude: |29| = 29 > 14 = |-14|

  12. Step 3 Subtract the smaller magnitude from the larger and enter the result.

  13. Work it out!

  14. Step 1 Same or opposite signs? They are both positive.

  15. Step 2 The sign is positive.

  16. Step 3 Add the magnitudes and enter the result.

  17. Work it out!

  18. Step 1 Same or opposite signs? They are both negative.

  19. Step 2 The sign is negative.

  20. Step 3 Add the magnitudes and enter the result.

  21. Adding Many Integers 1. Add all the positive numbers and add all the negative numbers: 2. Add the two signed numbers:

  22. Work it out!

  23. Work it out!

  24. Work it out!

  25. Work it out!

  26. Work it out!

  27. Work it out!

  28. Work it out!

  29. Work it out!

  30. Work it out!

  31. Work it out!

  32. Work it out!

  33. Work it out!

  34. Work it out!

  35. Work it out!

  36. Work it out!

  37. Work it out!

  38. Work it out! Rigid use of an algorithm is not always best.

  39. Work it out!

  40. Work it out!

  41. Moral Look before you leap! Many problems can be worked in your head if you do things in the right order.

More Related