1 / 88

Lecture 2

Decimal. Octal. Binary. Hexadecimal. ITEC 1000 “Introduction to Information Technology”. Lecture 2. Number Systems. Lecture Template:. Types of number systems Number bases Range of possible numbers Conversion between number bases Common powers Arithmetic in different number bases

bunme
Télécharger la présentation

Lecture 2

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. Decimal Octal Binary Hexadecimal ITEC 1000 “Introduction to Information Technology” Lecture 2 Number Systems

  2. Lecture Template: • Types of number systems • Number bases • Range of possible numbers • Conversion between number bases • Common powers • Arithmetic in different number bases • Shifting a number

  3. Types of Number Systems • Additive: Numbers have intrinsic value: e.g.: Roman Numerals: LVIII = 50 + 5 + 1 + 1 + 1 = 58 • Positional: Value depends on position: e.g.: Decimal system: 54 = 5 x 10 + 4 x 1 • Additive Number Systems are not used much any more: • Awkward to use. • Prone to errors.

  4. Definitions • The Base of a number system – how many different digits (incl. zero) are used in the system. Base 2: 0, 1 Base 5: 0, 1, 2, 3, 4 Base 8: 0, 1, 2, 3, 4, 5, 6, 7 Base 10: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Base 16: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F

  5. Definitions • Bit – a cell holding a single binary number (0 or 1) • Byte = 8 bits (can hold 28 = 256 different patterns/values) • Word – a fixed-sized group of bits that the computer handles together. Typical word sizes: 4, 8, 16, 32, 64, 128 bits • 1K = 1024 bytes

  6. Magnetic Core Memory http://en.wikipedia.org/wiki/Computer

  7. Common Number Systems

  8. Positional decimal system The number 125 means: 1 group of 100 (100 = 102) 2 groups of 10 (10 = 101) 5 groups of 1 (1 = 100)

  9. Place values (1 of 2) In our usual positional number system, the meaning of a digit depends on where it is located in the number Example: 3 7 3 2 3 groups of 1000 7 groups of 100 3 groups of 10 2 groups of 1

  10. Place values (2 of 2) Weight 12510 => 5 x 100 = 5 2 x 101 = 20 1 x 102 = 100 125 Base

  11. Representing in bases: 10, 2, 8, 16 • 86510 = 8 x 102 + 6 x 101 + 5 x 100 = 800 + 60 + 5 • 10112 = 1 x 23 + 0 x 22 + 1 x 21 + 1 x 20 = 8 + 2 + 1 = 1110 • 258 = 2 x 81 + 5 x 80 = 16 + 5 = 2110 • A716 = 10 x 161 + 7 x 160 = 160 + 7 = 16710 Note: The subscript naming the base is itself given in base ten (10), by convention. Base

  12. Counting in bases (1 of 3)

  13. Counting in bases (2 of 3)

  14. Counting in bases (3 of 3)

  15. Estimating magnitude: Binary

  16. Range of possible numbers • R = BK where • R = range • B = base • K = number of digits • Example #1: Base 10, 2 digits • R = 102 = 100 different numbers (0…99) • Example #2: Base 2, 16 digits • R = 216 = 65,536 or 64K • 16-bit PC can store 65,536 different number values

  17. Decimal Range for Bit Widths See also Ch. 2, p.33

  18. Decimal Octal Binary Hexadecimal Conversion Among Bases

  19. Decimal Octal Binary Hexadecimal Binary to Decimal (1 of 3)

  20. Binary to Decimal (2 of 3) • Technique • Multiply each bit by 2n, where n is the “weight” of the bit • The weight is the position of the bit, starting from 0 on the right • Add the results

  21. Bit “0” 1010112 => 1 x 20 = 1 1 x 21 = 2 0 x 22 = 0 1 x 23 = 8 0 x 24 = 0 1 x 25 = 32 4310 Binary to Decimal (3 of 3)

  22. Octal to Decimal (1 of 3) Decimal Octal Binary Hexadecimal

  23. Octal to Decimal (2 of 3) • Technique • Multiply each bit by 8n, where n is the “weight” of the bit • The weight is the position of the bit, starting from 0 on the right • Add the results together Note: 80 = 1, 81 = 8, 82 = 64 83 = 512, Etc.

  24. Octal to Decimal (3 of 3) 7248 => 4 x 80 = 4 x 1 = 4 2 x 81 = 2 x 8 = 16 7 x 82 = 7 x 64 = 448 46810

  25. Hexadecimal to Decimal (1 of 3) Decimal Octal Binary Hexadecimal

  26. Hexadecimal to Decimal (2 of 3) • Technique • Multiply each bit by 16n, where n is the “weight” of the bit • The weight is the position of the bit, starting from 0 on the right • Add the results Note: 160 = 1, 161 = 16, 162 = 256 163 = 4096, Etc.

  27. Hexadecimal to Decimal (3 of 3) ABC16 => C x 160 = 12 x 1 = 12 B x 161 = 11 x 16 = 176 A x 162 = 10 x 256 = 2560 274810

  28. Decimal to Binary (1 of 3) Decimal Octal Binary Hexadecimal

  29. Decimal to Binary (2 of 3) • Technique • Divide by two, keep track of the remainder • First remainder is bit 0 (LSB, least-significant bit) • Second remainder is bit 1 • Etc.

  30. 2 125 62 1 2 31 0 2 15 1 2 3 1 2 7 1 2 0 1 2 1 1 Decimal to Binary (3 of 3) 12510 = ?2 12510 = 11111012

  31. Octal to Binary (1 of 3) Decimal Octal Binary Hexadecimal

  32. Octal to Binary (2 of 3) • Technique • Convert each octal digit to a 3-bit equivalent binary representation See Table, Slides 12-14

  33. 7 0 5 111 000 101 Octal to Binary (3 of 3) 7058 = ?2 7058 = 1110001012

  34. Hexadecimal to Binary (1 of 3) Decimal Octal Binary Hexadecimal

  35. Hexadecimal to Binary (2 of 3) • Technique • Convert each hexadecimal digit to a 4-bit equivalent binary representation See Table, Slides 12-14

  36. 1 0 A F 0001 0000 1010 1111 Hexadecimal to Binary (3 of 3) 10AF16 = ?2 10AF16 = 00010000101011112

  37. Decimal to Octal (1 of 3) Decimal Octal Binary Hexadecimal

  38. Decimal to Octal (2 of 3) • Technique • Divide by 8 • Keep track of the remainder

  39. 8 19 2 8 2 3 8 0 2 Decimal to Octal (3 of 3) 123410 = ?8 8 1234 154 2 123410 = 23228

  40. Decimal to Hexadecimal (1 of 3) Decimal Octal Binary Hexadecimal

  41. Decimal to Hexadecimal (2 of 3) • Technique • Divide by 16 • Keep track of the remainder

  42. 16 1234 77 2 16 4 13 = D 16 0 4 Decimal to Hexadecimal (3 of 3) 123410 = ?16 123410 = 4D216

  43. Binary to Octal (1 of 3) Decimal Octal Binary Hexadecimal

  44. Binary to Octal (2 of 3) • Technique • Group bits in threes, starting on right • Convert to octal digits See Table, Slides 12-14

  45. 1 011 010 111 1 3 2 7 Binary to Octal (3 of 3) 10110101112 = ?8 10110101112 = 13278

  46. Binary to Hexadecimal (1 of 3) Decimal Octal Binary Hexadecimal

  47. Binary to Hexadecimal (2 of 3) • Technique • Group bits in fours, starting on right • Convert to hexadecimal digits See Table, Slides 12-14

  48. Binary to Hexadecimal (3 of 3) 10101110112 = ?16 10 1011 1011 2 B B 10101110112 = 2BB16

  49. Octal to Hexadecimal (1 of 3) Decimal Octal Binary Hexadecimal

  50. Octal to Hexadecimal (2 of 3) • Technique • Use binary as an intermediary See Table, Slides 12-14

More Related