Presentation is loading. Please wait.

Presentation is loading. Please wait.

Algorithms for Integer Arithmetic

Similar presentations


Presentation on theme: "Algorithms for Integer Arithmetic"— Presentation transcript:

1 Algorithms for Integer Arithmetic
Addition Algorithm

2 Three Steps to Adding Two Integers
Do they have the same sign? (both positive or both negative) or Do they have opposite signs? (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 2. Add the two signed numbers:
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.


Download ppt "Algorithms for Integer Arithmetic"

Similar presentations


Ads by Google