1 / 19

Section 2.6

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 from {0,1,2,3,4,5,6,7,8,9} that looks like where.

tad-harper
Download Presentation

Section 2.6

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. 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×103 + 0×102 + 3×101 + 7×100

  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×24 + 0×23 + 1×22 + 1×21 + 1×20

  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×103 + 0×102 + 3×101 + 7×100 (231)eight = 2×82 + 3×81 + 1×80 (403)five = 4×52 + 0×51 + 3×50

  13. Practice (5401)six = (_____________)ten

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

  15. Practice (1203)ten = (_____________)five

  16. Practice (1203)ten = (_____________)two

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

  18. Proving these properties Claim. For all n 0, 10n – 1 is divisible by 3. Proof by induction. Consider the statement P(n) that states, “an 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 “am-1 is divisible by 3.” This means that am-1 = 3K for some integer K. From this it follows that am = 10(am-1) + 9 = 10(3K) + 9 = 3 (10K + 3)Since 10K + 3 is an integer, we can conclude that am 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 = ck10k + … + c1 101 + c0100, and this means that S = ck + … + c1 + c0, from which it follows that n – S = ck(10k – 1) + … + c1 (101 – 1) + (c0 – 1)100,Each of 10k – 1, …, 101 – 1, and 100 – 1 is divisible by 3, so n – S is divisible by 3.

More Related