Algorithms for Integer Arithmetic

The Integers
Definitions
Think about the game!
• When working with negative numbers,
think about what it means in the
MathGym-1D game.
• Which direction does the answer move
something? (Is answer is positive or
negative?)
• How far does it move it? (What is the
size of the answer? )
What is an Integer?
• The integers are made up of the
counting numbers, now called the
positive integers:
1, 2, 3, 4, …
• The negative numbers
-1, -2, -3, -4, …
• And zero
0
More Words to Learn
• We will use the capital letter Z (from
the German word “zahlen”) to denote
the set of integers.
• The positive numbers should be written
as +1, +2, +3, +4, …, but we usually drop
the + as unnecessary.
• The symbols + and – are called the sign
of the number.
The Basics
• The game shows that -(-3) = 3, so
3 + (-3) = 0 and (-3) + (-(-3)) = 0
• You can see that
n + (-n) = 0
for every integer n.
• Also
n+0=0+n=n
for every n.
Absolute value
• The absolute value or magnitude or size of
a number is how far it moves something,
regardless of direction.
• Compute it by dropping the sign.
• It is always greater than or equal to 0.
2 2
2  2
0.0001  0.0001
56.132  56.132
The Number Line
• Lay out equally spaced points on a line and
label them with the integers:
• The numbers act just like street
addresses, they tell you where to go.
• The arrow points in the positive direction.
• Later we will make up new numbers to give
addresses to the other points.
Work it out!
2  2
Work it out!
2  2
Work it out!
0 0
Work it out!
0 0
Work it out!
2 2
Work it out!
2 2
Work it out!
27  27
Work it out!
27  27
Work it out!
3.4567  3.4567
Work it out!
3.4567  3.4567
Work it out!
0.0003  0.0003
Work it out!
0.0003  0.0003
Work it out!
1,200,325  1,200,325
Work it out!
1,200,325  1,200,325
Work it out!
( 10)9  109  1,000,000,000
Work it out!
( 10)9  109  1,000,000,000
Work it out!
( 10)9  109  1,000,000,000