* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Section3.1
Survey
Document related concepts
Transcript
Section 3.1: Number Representation Practice HW (not to hand in) From Barr Text p. 185 # 1-5 Representation of Numbers • Ordinary numbers we see every day are represented as base 10, that is, as the sum of the powers of 10. We illustrate how this is so in the following example. • So far, we have studied historical cryptographic methods that are typically hand-based. Modern cryptographic methods are computer based methods. To have an appreciation for these methods, we need to understand how computers communicate. In this section, we study the types of numbers that computers typically work with. Example 1: Write the number 12341 as a sum of the powers of 10. Solution: Binary Numbers are base 2 numbers are made up only of 0’s and 1’s. Computers use these numbers to represent data internally. Examples of binary numbers are 0 (which represents the number 0) 100 (which represents the number 4), 1001 (which represents the number 9), and 1011000 (which represents the number 88). We now give a formal definition of a binary number. Definition A binary number bk bk 1 b2b1b0, where bi 0 or 1, represents the base 10 decimal number given by bk 2 bk 1 2 k k 1 b2 2 b1 2 b0 2 2 1 0 We illustrate this definition in the following examples. Example 2: Find the base 10 decimal representation of the binary numbers a. 100 Solution: b. 1011000 Solution: c. 1110001011 Solution: Note • To convert a decimal (base 10) number to binary, we compute the powers of 2 (starting with 20 ) that are less than the given number. Then write the number as a sum of these powers of 2 from largest to smallest, writing a coefficient of 1 in front the power of 2 that occurs in the sum and a 0 in front of the power of 2 that does not occur. Reading off the coefficients from left to right gives the binary representation. We illustrate this technique in the following examples. Example 3: Convert 77 to binary. Solution: Example 4: Convert 320 to binary. Solution: Approximating the Size of a Binary Number • Many times the strength of a cryptographic method is expressed in terms of the size of a particular parameter. Many times the size of this parameter is expressed in terms on the number of binary digits the number has. The following formula gives an estimate of the number of binary digits is required to expressed a given base 10 decimal number. Number of Binary Digits Estimate ln( n) b ln( 2) where n base 10 decimal number b approximat e number of binary digits in the given number Example 5: Approximate how many binary digits are used to represent the number 430121. Solution: • The following inequality gives a bound of the size of a base 10 number given the number of binary digits that represent it. Base 10 Number Size Binary Bound Estimate b 1 2 n 2 , where b n base 10 decimal number b approximat e number of binary digits in the given number Example 6: A base 10 number is represented by a 32 bit number. Find a bound that will estimate its size. Solution: ASCII Codes for Characters • So far, we have used the MOD 26 alphabet assignment table to assign a numerical representation to each letter. Computers normally use the ASCII (American Standard Code for Information Interchange) table for obtaining numerical representation of characters. Table 1: ASCII table for characters Example 7: Find the numerical Ascii table representation for the characters z, Z, “, and a space. Solution: Example 8: Decode the following text represented by the 8-bit blocks representing Ascii code numbers: 01001101 01001111 01000100 00110010 Solution: