41
Algorithms for Algorithms for Integer Arithmetic Integer Arithmetic Addition Algorithm Addition Algorithm

Addition Algorithm

Embed Size (px)

DESCRIPTION

Addition Algorithm

Citation preview

Page 1: Addition Algorithm

Algorithms for Integer Algorithms for Integer ArithmeticArithmetic

Algorithms for Integer Algorithms for Integer ArithmeticArithmeticAddition AlgorithmAddition Algorithm

Page 2: Addition Algorithm

Three Steps to Adding Two Integers

STEP 1. Do they have the same sign?(both positive or both negative)

orDo they have opposite signs? (one positive and the other negative)

Page 3: Addition Algorithm

Same Signs

9 11 20, ( 3) ( 17) 20

9 11 ?, ( 3) ( 17) ?

STEP 3. Now enter the sum of the absolute values: (add the magnitudes)

STEP 2. Enter the common sign:

9 11 , ( 3) (20 21 07)

Page 4: Addition Algorithm

Opposite Signs

17 3 14

3 ( 17) ?

STEP 3. Enter the difference of the larger magnitude and the smaller:

STEP 2. Enter the sign of the number having the larger magnitude:

3 ( 17 14)

3 ( 17) 14

Page 5: Addition Algorithm

Work it out!

12 ( 34 22)

Page 6: Addition Algorithm

Step 1

12 ( 34 22)

They have opposite signs.

Same or opposite signs?

Page 7: Addition Algorithm

Step 2

12 ( 34 22)

Enter the sign of the number having the larger magnitude:

|-34| = 34 > 12 = |12|

Page 8: Addition Algorithm

Step 3

12 ( 34) 22

Subtract the smaller magnitude from the larger and enter the result.

Page 9: Addition Algorithm

Work it out!

29 114 5

Page 10: Addition Algorithm

Step 1

29 14 29 ( 14)

They have opposite signs.

Same or opposite signs?

Page 11: Addition Algorithm

Step 2

29 114 5

Enter the sign of the number having the larger magnitude:

|29| = 29 > 14 = |-14|

Page 12: Addition Algorithm

Step 3

29 14 15

Subtract the smaller magnitude from the larger and enter the result.

Page 13: Addition Algorithm

Work it out!

12 14 6

Page 14: Addition Algorithm

Step 1

12 14 6

They are both positive.

Same or opposite signs?

Page 15: Addition Algorithm

Step 2

12 14 6

The sign is positive.

Page 16: Addition Algorithm

Step 3

12 4 16

Add the magnitudes and enter the result.

Page 17: Addition Algorithm

Work it out!

( 2) ( 119)

Page 18: Addition Algorithm

Step 1

( 2) ( 119)

They are both negative.

Same or opposite signs?

Page 19: Addition Algorithm

Step 2

( 2) ( 119)

The sign is negative.

Page 20: Addition Algorithm

Step 3

( 2) ( 9) 11

Add the magnitudes and enter the result.

Page 21: Addition Algorithm

Adding Many Integers

2 8 7 3 2 ( 8) 7 ( 3)

1. Add all the positive numbers and add all the negative numbers:

2 7 9 , ( 8) ( 3) 11

2. Add the two signed numbers:9 ( 11) 2Answer.

Page 22: Addition Algorithm

12 14 6

Work it out!

Page 23: Addition Algorithm

12 4 16

Work it out!

Page 24: Addition Algorithm

16( 12) 4

Work it out!

Page 25: Addition Algorithm

( 12) 4 16

Work it out!

Page 26: Addition Algorithm

(2 4 1) (( 5) ( 3))

7

2 4 ( 5) ( 3

)

) 1

( 8 1

Work it out!

Page 27: Addition Algorithm

2 4 ( 5) ( 3) 1

(2 4 1) ((

7 (

5) ( 3))

8) 1

Work it out!

Page 28: Addition Algorithm

2 4 ( 5) ( 3) 1

(2 4 1) (( 5) ( 3))

7 ( 18)

Work it out!

Page 29: Addition Algorithm

2 4 ( 5) ( 3) 1

(2 4 1) (( 5) ( 3))

7 ( 8) 1

Work it out!

Page 30: Addition Algorithm

9 2 4 (4 1 3)

15 8

4 2

7

9 1 4 3

Work it out!

Page 31: Addition Algorithm

9 4 2 1 4 3

9 2 4 (

15

4 1 3)

8 7

Work it out!

Page 32: Addition Algorithm

9 4 2 1 4 3

9 2 4 (4 1 3)

15 78

Work it out!

Page 33: Addition Algorithm

9 4 2 1 4 3

9 2 4 (4 1 3)

15 8 7

Work it out!

Page 34: Addition Algorithm

12.7 1.3 5.0

12.7 1.3 1

(15.6

5.6 5.0 3.4

3.4)

19.0 19.0 0

Work it out!

Page 35: Addition Algorithm

12.7 1.3 15.6 5.0 3.4

12.7 1.3 5.0 (15.6 3.4)

19.0 19.0 0

Work it out!

Page 36: Addition Algorithm

12.7 1.3 15.6 5.0 3.4

12.7 1.3 5.0 (15.6 3.4)

19.0 1 09.0

Work it out!

Page 37: Addition Algorithm

12.7 1.3 15.6 5.0 3.4

12.7 1.3 5.0 (15.6 3.4)

19.0 19.0 0

Work it out!

Page 38: Addition Algorithm

Work it out!

100 7

2 5 7 3

2 5 7

4 6

4

1

3 6

7

Rigid use of an algorithm is not always best.

Page 39: Addition Algorithm

Work it out!

100 7

2 5 7 3 4 6

2 7 13 75 4 6

Page 40: Addition Algorithm

Work it out!

100 7

2 5 7 3 4 6

2 5 7 3 4 6 17

Page 41: Addition Algorithm

Moral

Look before you leap!

Many problems can be worked in your head if you do things in the right order.

2 5 7 3 4 6 17