Presentation is loading. Please wait.

Presentation is loading. Please wait.

Section 2.6 Representation of numbers. Decimal representation (base 10) Given a positive integer X, the decimal representation of X is a string of digits.

Similar presentations


Presentation on theme: "Section 2.6 Representation of numbers. Decimal representation (base 10) Given a positive integer X, the decimal representation of X is a string of digits."— Presentation transcript:

1 Section 2.6 Representation of numbers

2 Decimal representation (base 10) Given a positive integer X, the decimal representation of X is a string of digits from {0,1,2,3,4,5,6,7,8,9} that looks like where Ex: (2037) ten = 2×10 3 + 0×10 2 + 3×10 1 + 7×10 0

3 Prove: Multiplying a decimal number by 10 shifts the digits one place to the left and places a “0” on the end.

4 Base two representation Given a positive integer X, the binary representation of X is a string of digits from {0,1} that looks like where Ex: (10111) two = 1×2 4 + 0×2 3 + 1×2 2 + 1×2 1 + 1×2 0

5 Let x=(10101) two What decimal number represents x? What is the binary representation for 2x?

6 Multiplying Binary Numbers by 2 Note that the binary numeral for 2x is formed by shifting the x bits to the left and placing a “0”on the right. For 2x+1 we place a “1” on the right after doing the shift.

7 The binary representation for 14 is 1110. What is the binary representation for 29? By the division theorem, 29=2*14+1, so…

8 Every natural number has a binary representation. Proof by Induction: Let P(n) be the statement “n has a binary representation”. Check that P(n) is true for the base case. Note that P(0) and P(1) holds. Now suppose that P(2), P(3), …., P(m-1) have been check for some m >1.

9 Prove that P(m) holds. By the division theorem, there are integers q and r such that (1) m=2q+r and (2) r is from the set {0,1}. Since q<m, P(q) has been checked, so we know q has a binary representation:. So, Now, m=2q+r So the binary representation for m is

10 The proof tells us how to write a number in base 2: Input a natural number n While n>0, do the following:  Divide n by 2 and get a quotient q and remainder r.  Write r as the next (right-to-left) digit.  Replace the value of n and q, and repeat.

11 Write the base 10 number 65 in base 2. Begin with n=35. 35/2 = 17 with remainder 1, so write 1, and let n=17. 17/2=8 with remainder 1, so write 1, and let n=8. 8/2=4 with remainder 0, so write 0, and let n=4. 4/2=2 with remainder 0, so write 0,and let n=2. 2/2=1 with remainder 0, so write 0,and let n=1 ½=0 with remainder 1, so write 1, and let n=0. Since n=0, quit. The numeral is then 100011.

12 Examples of other “place value systems” (2037) ten = 2×10 3 + 0×10 2 + 3×10 1 + 7×10 0 (231) eight = 2×8 2 + 3×8 1 + 1×8 0 (403) five = 4×5 2 + 0×5 1 + 3×5 0

13 Practice (5401) six = (_____________) ten

14 Converting to other bases Example. (2037) ten = (____________) eight 2037 ÷ 8Quo 254Rem 5 254 ÷ 8Quo 31Rem 6 31 ÷ 8Quo 3Rem 7 3 ÷ 8Quo 0Rem 3 Answer. (2037) ten = (3765) eight

15 Practice (1203) ten = (_____________) five

16 Practice (1203) ten = (_____________) two

17 Claim. For all n  0, 10 n – 1 is divisible by 3. Before beginning the proof, let’s define a n = 10 n – 1. From this closed formula, it is easy to see that the following recursive description is the same thing: “a 0 = 0, a n = 10*a n-1 + 9.” We will prove that “a n is divisible by 3” for all n  0.

18 Proving these properties Claim. For all n  0, 10 n – 1 is divisible by 3. Proof by induction. Consider the statement P(n) that states, “a n is divisible by 3.” It is easy to check the base case. P(0) says, “0 is divisible by 3,” which is true. Now let m be the first number for which P(m) has not yet been checked. In particular, P(m – 1) has been checked, so we know that “a m-1 is divisible by 3.” This means that a m-1 = 3K for some integer K. From this it follows that a m = 10(a m-1 ) + 9 = 10(3K) + 9 = 3 (10K + 3) Since 10K + 3 is an integer, we can conclude that a m is divisible by 3.

19 Proving properties Claim. If S be the sum of the (base ten) digits in n, then n – S is divisible by 3. Proof. We can represent n = c k 10 k + … + c 1 10 1 + c 0 10 0, and this means that S = c k + … + c 1 + c 0, from which it follows that n – S = c k (10 k – 1) + … + c 1 (10 1 – 1) + (c 0 – 1)10 0, Each of 10 k – 1, …, 10 1 – 1, and 10 0 – 1 is divisible by 3, so n – S is divisible by 3.


Download ppt "Section 2.6 Representation of numbers. Decimal representation (base 10) Given a positive integer X, the decimal representation of X is a string of digits."

Similar presentations


Ads by Google