1 / 61

Number Systems

Number Systems. A Brief History of Numbers. From Gonick, Cartoon Guide to Computer Science. Prehistoric Ledgers. Elaborate Finger Counting. Ancient Number Systems. Positional Number Systems. Number Systems. Prehistory Unary, or marks: /////// = 7 /////// + ////// = /////////////

Download Presentation

Number Systems

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. Number Systems 1

  2. A Brief History of Numbers From Gonick, Cartoon Guide to Computer Science 2

  3. 3

  4. 4

  5. Prehistoric Ledgers 5

  6. 6

  7. Elaborate Finger Counting 7

  8. 8

  9. 9

  10. 10

  11. Ancient Number Systems 11

  12. 12

  13. Positional Number Systems 13

  14. 14

  15. 15

  16. 16

  17. 17

  18. 18

  19. Number Systems • Prehistory Unary, or marks: /////// = 7 /////// + ////// = ///////////// • Grouping lead to Roman Numerals: VII + V = VVII = XII • Better, Arabic Numerals: 7 + 5 = 12 = 1 x 10 + 2 19

  20. Positional Number System • Base 10 is a special case of positional number system • PNS First used over 4000 years ago in Mesopotamia (Iraq) • Base 60 • 0...59 (written as 60 different symbols) • 5,4560 = 5 x 60 + 45 = 34510 • Positional Number Systems are great for algebra • Why? 20

  21. Arabic Numerals • 345 is really • 3 x 102 + 4 x 101 + 5 x 100 • 3 x 100 + 4 x 10 + 5 x 1 • 3 is the most significant symbol (carries the most weight) • 5 is the least significant symbol (carries the least weight) • Digits (or symbols) allowed: 0-9 • Base (or radix): 10 21

  22. Positional Number System • Try multiplication in (non-positional) Roman numerals! • XXXIII (33 in decimal) • XII (12 in decimal) • --------- • XXXIII • XXXIII • CCCXXX • ----------- • CCCXXXXXXXXXIIIIII----------- • CCCLXXXXVI • -----------CCCXCVI = 396 in decimal * The Mesopotamians wouldn’t have had this problem!! + 22

  23. Positional Number System • There are many ways to “represent” a number • Representation does not affect computation result • LIX + XXXIII = LXXXXII (Roman) • 59 + 33 = 92 (Decimal) • Representation affects difficulty of computing results • Computers need a representation that works with fast electronic circuits • Positional numbers work great with 2-state devices 23

  24. 24

  25. 25

  26. What ’10’ Means 26

  27. Number Base Systems 27

  28. Binary Numbers 28

  29. 29

  30. The Powers of 2 30

  31. 31

  32. Equivalent Numbers 32

  33. Converting Binary to Decimal 33

  34. Binary Number System • Base (radix): 2 • Digits (symbols) allowed: 0, 1 • Binary Digits, or bits • 10012 is really • 1 x 23 + 0 x 22 + 0 X 21 + 1 X 20 • 910 • 110002 is really • 1 x 24 + 1 x 23 + 0 x 22 + 0 x 21 + 0 x 20 • 2410 34

  35. Binary Number System So if the computer is all binary how does it multiply 5 by 324 when I type it in the calculator program? Computers multiply Arabic numerals by converting to binary, multiplying and converting back (much as us with Roman numerals) 35

  36. Octal Number System • Base (radix): 8 • Digits (symbols): 0 – 7 • 3458 is really • 3 x 82 + 4 x 81 + 5 x 80 • 192 + 32 + 5 • 22910 • 10018 is really • 1 x 83 + 0 x 82 + 0 x 81 + 1 x 80 • 512 + 1 • 51310 • In C, octal numbers are represented with a leading 0 (0345 or 01001). 36

  37. Hexadecimal Number System • Base (radix): 16 • Digits (symbols) allowed: 0 – 9, a – f 37

  38. Hexadecimal Number System Some Examples of converting hex numbers to decimal • A316 is really: • A x 161 + 3 x 160 • 160 + 3 • 16310 • 3E816 is really: • 3 x 162 + E x 161 + 8 x 160 • 3 x 256 + 14 x 16 + 8 x 1 • 768 + 224 + 8 • 100010 38

  39. Hexadecimal Number System • 10C16 is really: • 1 x 162 + 0 x 161 + C x 160 • 1 x 256 + 12 x 16 • 256 + 192 • 44810 • In C, hex numbers are represented with a leading “0x” (for example “0xa3” or “0x10c”). 39

  40. Positional Number System n-1 Value = Σ (Sibi) i=0 • For any positional number system • Base (radix): b • Digits (symbols): 0 … b – 1 • Sn-1Sn-2….S2S1S0 • Use summation to transform any base to decimal 40

  41. More PNS fun • 21203 = • 4035 = • 2717 = • 3569 = • 11102 = • 2A612 = • BEEF16 = =6910 =10310 =4110 =29410 =1410 =41410 =4887910 41

  42. Decimal  Binary Conversion • Divide decimal value by 2 until the value is 0 • Know your powers of two and subtract • … 256 128 64 32 16 8 4 2 1 • Example: 42 • What is the biggest power of two that fits? • What is the remainder? • What fits? • What is the remainder? • What fits? • What is the binary representation? 42

  43. Decimal  Binary Conversion 43

  44. Decimal  Binary Conversion • 12810= • 31010= • 2610= 44

  45. Binary  Octal Conversion • Group into 3’s starting at least significant symbol • Add leading 0’s if needed (why not trailing?) • Write 1 octal digit for each group • Examples: • 100 010 111 (binary) • 4 2 7 (octal) • 10 101 110 (binary) • 2 5 6 (octal) 45

  46. Octal  Binary Conversion It is simple, just write down the 3-bit binary code for each octal digit 46

  47. Binary Hex Conversion • Group into 4’s starting at least significant symbol • Adding leading 0’s if needed • Write 1 hex digit for each group • Examples: • 1001 1110 0111 0000 • 9 e 7 0 • 0001 1111 1010 0011 • 1 f a 3 47

  48. Hex  Binary Conversion • Again, simply write down the 4 bit binary code for each hex digit • Example: • 3 9 c 8 • 0011 1001 1100 1000 48

  49. Conversion Table 49

  50. 50

More Related