1 / 10

Basic Data Types

8 1. 8 92. 8 11. Octal/Hexadecimal. Note that the methods we used to convert from decimal to binary, and back again, work for any base. Basic Data Types. If, for example we wished to convert 92 10 to Octal (base 8):. Remainder. 92 10 =. 1. 3. 4 8. 4. Check:.

Télécharger la présentation

Basic Data Types

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. 8 1 8 92 8 11 Octal/Hexadecimal Note that the methods we used to convert from decimal to binary, and back again, work for any base. Basic Data Types If, for example we wished to convert 9210 to Octal (base 8): Remainder 9210 = 1 3 4 8 4 Check: Position: 2 1 0 3 Number: 1 3 4 Value: 1* 82 + 3 * 81 + 4 * 80 1 = 1* 64 + 3 * 8 + 4 * 1 = 64 + 24 + 4 0 = 92 Since the new quotient is 0, collect from last to first

  2. Why would I care about octal (base 8) ?? Basic Data Types As it turns out, Octal AND Hexadecimal (base 16) are often used because they allow for easy conversion to and from binary. Why is Octal easy ?? Since Octal consists ONLY of the digits 0 through 7, ANY octal digit can be represented using only 3 bits: Octal Binary Octal Binary 0 000 4 100 5 1 001 101 2 010 6 110 3 011 7 111

  3. 1011100 = 1 011 100 1 3 4 (Check against Table) Why is that easy? Basic Data Types Consider the binary number 10111002 (which is 9210 and 1348 - see the previous example) Notice that there is a direct transference from binary to octal and octal to binary.

  4. 2 457 2 228 2 114 2 57 2 28 2 14 2 7 2 3 2 1 Example 2: Consider the number 45710 Basic Data Types 1 1 1 1 0 0 1 0 0 12 = 45710 0 In Octal ?? 0 111 001 001 1 7 1 1 = 7118 0 Sure?? 0 7118 = 7 * 82 + 1 * 81 + 1 * 80 1 = 7 * 64 + 1 * 8 + 1 * 1 1 = 448 + 8 + 1 1 = 457 Stop and Collect

  5. Digit Binary Digit Binary 0 0000 8 1000 1 0001 9 1001 2 0010 10 1010 3 0011 11 1011 4 0100 12 1100 5 0101 13 1101 6 0110 14 1110 7 0111 15 1111 What about Hexadecimal (Base 16) ?? Basically, Hex is used for the same reason: It is easy to convert Basic Data Types Since 24 = 16 pieces of information, we can represent all the digits between 0 and 15:

  6. Digit Binary Digit Binary 0 0000 8 1000 1 0001 9 1001 2 0010 A 1010 3 0011 B 1011 4 0100 C 1100 5 0101 D 1101 6 0110 E 1110 7 0111 F 1111 But 10, 11, 12, 13, 14, and 15 are NOT digits. They are Combinations of digits. Basic Data Types True. We need to substitute the symbols: A = 10 B = 11 C = 12 D = 13 E = 14 F = 15 The Conversion Table Should be:

  7. Once again, consider the binary number 10111002 = 9210 = 1348 - see the prior example Basic Data Types What is the Hexadecimal Value ?? 101 1100 = 5C16 5 C Sure??? 5C16 = 5 * 161 + C * 160 = 5 * 161 + 12 * 160 = 5 * 16 + 12 * 1 = 80 + 12 = 92

  8. 2 486 2 243 2 121 2 60 2 30 2 15 2 7 2 3 2 1 Example 2: Consider the number 48610 Basic Data Types 0 1 1 1 1 0 0 1 1 02 = 48610 1 In Hexadecimal ?? 1 1 1110 0110 0 1 E 6 = 1E616 Sure?? 0 1E616 = 1 * 162 + E * 161 + 6 * 160 1 = 1 * 162 + 14 * 161 + 6 * 160 1 = 1 * 256 + 14 * 16 + 6 * 1 = 256+ 224 + 6 1 = 486 1 Stop and Collect

  9. 8 47 8 5 16 2 16 47 What about Converting from Octal to Hexadecimal?? The easiest way is to use binary numbers: Basic Data Types 578 = 5 7 1 0 1 1 1 1 2 F = 2F16 Sure??? 1011112 = 25 + 23 + 22 + 21 + 20 = 32 + 8 + 4 + 2 + 1 = 4710 Octal Hexadecimal 2F 7 15 = F 5 2 57

  10. This Concludes The Slides for this Section Choose an Option:  Repeat Slides for this Section  Go To Next Set of Slides For this Chapter  Go To Slide Index For Chapter 2  Go To Slide Index For Chapter 3  Go To Slide Index For Textbook  Go To Home Page

More Related