Successfully reported this slideshow.
Upcoming SlideShare
×

# 01.number systems

1,963 views

Published on

• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

### 01.number systems

1. 1. 1. Number Systems Chapt. 2 Location in course textbook
2. 2. Bit & Byte <ul><ul><li>Computer uses the binary system .  </li></ul></ul><ul><ul><li>Any physical system that can exist in two distinct states (e.g., 0-1, on-off, hi-lo, yes-no, up-down, north-south, etc.) has the potential of being used to represent numbers or characters . </li></ul></ul><ul><ul><li>A binary digit is called a  bit . There are two possible states in a bit, usually expressed as 0 and 1. </li></ul></ul><ul><ul><ul><li>  </li></ul></ul></ul><ul><ul><ul><li>A series of eight bits strung together makes a  byte , much as 12  makes a dozen.  </li></ul></ul></ul><ul><ul><ul><li>With 8 bits, or 8 binary digits, there exist 2^ 8 =256 possible combinations. </li></ul></ul></ul>
3. 3. combinations <ul><ul><li>The following table shows some of these combinations. (The number enclosed in parentheses represents the decimal equivalent.) </li></ul></ul><ul><ul><li>00000000 ( 0) 00010000 ( 16) 00100000 ( 32) ... 01110000 (112) 00000001 ( 1) 00010001 ( 17) 00100001 ( 33) ... 01110001 (113) 00000010 ( 2) 00010010 ( 18) 00100010 ( 34) ... 01110010 (114) 00000011 ( 3) 00010011 ( 19) 0010011 ( 35) ... 01110011 (115) 00000100 ( 4) 00010100 ( 20) 00100100 ( 36) ... 01110100 (116) 00000101 ( 5) 00010101 ( 21) 00100101 ( 37) ... 01110101 (117) 00000110 ( 6) 00010110 ( 22) 00100110 ( 38) ... 01110110 (118) 00000111 ( 7) 00010111 ( 23) 00100111 ( 39) ... 01110111 (119) 00001000 ( 8) 00011000 ( 24) 00101000 ( 40) ... 01111000 (120) 00001001 ( 9) 00011001 ( 25) 00101001 ( 41) ... 01111001 (121) 00001010 ( 10) 00011010 ( 26) 00101010 ( 42) ... 01111010 (122) 00001011 ( 11) 00011011 ( 27) 00101011 ( 43) ... 01111011 (123) 00001100 ( 12) 00011100 ( 28) 00101100 ( 44) ... 01111100 (124) 00001101 ( 13) 00011101 ( 29) 00101101 ( 45) ... 01111101 (125) 00001110 ( 14) 00011110 ( 30) 00101110 ( 46) ... 01111110 (126) 00001111 ( 15) 00011111 ( 31) 00101111 ( 47) ... 01111111 (127)   </li></ul></ul>
4. 4. Decimal <ul><li>  For example,          1234       :     means that there are four boxes (digits); and there are 4 one's in the right-most box (least significant digit), 3 ten's in the next box, 2 hundred's in the next box, and finally 1 thousand's in the left-most box (most significant digit). The total is 1234: </li></ul><ul><li>Original Number: 1 2 3 4 </li></ul><ul><li>| | | | </li></ul><ul><li>How Many Tokens: 1 2 3 4 </li></ul><ul><li>Digit/Token Value: 1000 100 10 1 </li></ul><ul><li>Value: 1000 + 200 + 30 + 4 = 1234 </li></ul><ul><li>or simply, 1*1000 + 2*100 + 3*10 + 4*1 = 1234, </li></ul><ul><li>Thus, each digit has a value : 10^ 0 =1 for the least significant digit, increasing to 10^ 1 =10, 10^ 2 =100, 10^ 3 =1000, and so forth. </li></ul>
5. 5. Common Number Systems System Base Symbols Used by humans? Used in computers? Decimal 10 0, 1, … 9 Yes No Binary 2 0, 1 No Yes Octal 8 0, 1, … 7 No No Hexa- decimal 16 0, 1, … 9, A, B, … F No No
6. 6. Quantities/Counting (1 of 3) p. 33 Decimal Binary Octal Hexa- decimal 0 0 0 0 1 1 1 1 2 10 2 2 3 11 3 3 4 100 4 4 5 101 5 5 6 110 6 6 7 111 7 7
7. 7. Quantities/Counting (2 of 3) Decimal Binary Octal Hexa- decimal 8 1000 10 8 9 1001 11 9 10 1010 12 A 11 1011 13 B 12 1100 14 C 13 1101 15 D 14 1110 16 E 15 1111 17 F
8. 8. Quantities/Counting (3 of 3) Etc. Decimal Binary Octal Hexa- decimal 16 10000 20 10 17 10001 21 11 18 10010 22 12 19 10011 23 13 20 10100 24 14 21 10101 25 15 22 10110 26 16 23 10111 27 17
9. 9. Conversion Among Bases <ul><li>The possibilities: </li></ul>Hexadecimal Decimal Octal Binary pp. 40-46
10. 10. Quick Example 25 10 = 11001 2 = 31 8 = 19 16 Base
11. 11. Decimal to Decimal (just for fun) Hexadecimal Decimal Octal Binary Next slide…
12. 12. 125 10 => 5 x 10 0 = 5 2 x 10 1 = 20 1 x 10 2 = 100 125 Base Weight
13. 13. Binary to Decimal Hexadecimal Decimal Octal Binary
14. 14. Binary to Decimal <ul><li>Technique </li></ul><ul><ul><li>Multiply each bit by 2 n , where n is the “ weight ” of the bit </li></ul></ul><ul><ul><li>The weight is the position of the bit, starting from 0 on the right </li></ul></ul><ul><ul><li>Add the results </li></ul></ul>
15. 15. Example 101011 2 => 1 x 2 0 = 1 1 x 2 1 = 2 0 x 2 2 = 0 1 x 2 3 = 8 0 x 2 4 = 0 1 x 2 5 = 32 43 10 Bit “ 0 ”
16. 16. Octal to Decimal Hexadecimal Decimal Octal Binary
17. 17. Octal to Decimal <ul><li>Technique </li></ul><ul><ul><li>Multiply each bit by 8 n , where n is the “ weight ” of the bit </li></ul></ul><ul><ul><li>The weight is the position of the bit, starting from 0 on the right </li></ul></ul><ul><ul><li>Add the results </li></ul></ul>
18. 18. Example 724 8 => 4 x 8 0 = 4 2 x 8 1 = 16 7 x 8 2 = 448 468 10
20. 20. Hexadecimal to Decimal <ul><li>Technique </li></ul><ul><ul><li>Multiply each bit by 16 n , where n is the “ weight ” of the bit </li></ul></ul><ul><ul><li>The weight is the position of the bit, starting from 0 on the right </li></ul></ul><ul><ul><li>Add the results </li></ul></ul>
21. 21. Example ABC 16 => C x 16 0 = 12 x 1 = 12 B x 16 1 = 11 x 16 = 176 A x 16 2 = 10 x 256 = 2560 2748 10
22. 22. Decimal to Binary Hexadecimal Decimal Octal Binary
23. 23. Decimal to Binary <ul><li>Technique </li></ul><ul><ul><li>Divide by two, keep track of the remainder </li></ul></ul><ul><ul><li>First remainder is bit 0 (LSB, least-significant bit) </li></ul></ul><ul><ul><li>Second remainder is bit 1 </li></ul></ul><ul><ul><li>Etc. </li></ul></ul>
24. 24. Example 125 10 = ? 2 125 10 = 1111101 2 2 125 62 1 2 31 0 2 15 1 2 7 1 2 3 1 2 1 1 2 0 1
25. 25. Octal to Binary Hexadecimal Decimal Octal Binary
26. 26. Octal to Binary <ul><li>Technique </li></ul><ul><ul><li>Convert each octal digit to a 3-bit equivalent binary representation </li></ul></ul>
27. 27. Example 705 8 = ? 2 705 8 = 111000101 2 7 0 5 111 000 101
29. 29. Hexadecimal to Binary <ul><li>Technique </li></ul><ul><ul><li>Convert each hexadecimal digit to a 4-bit equivalent binary representation </li></ul></ul>
30. 30. Example 10AF 16 = ? 2 10AF 16 = 0001000010101111 2 1 0 A F 0001 0000 1010 1111
31. 31. Decimal to Octal Hexadecimal Decimal Octal Binary
32. 32. Decimal to Octal <ul><li>Technique </li></ul><ul><ul><li>Divide by 8 </li></ul></ul><ul><ul><li>Keep track of the remainder </li></ul></ul>
33. 33. Example 1234 10 = ? 8 8 1234 154 2 1234 10 = 2322 8 8 19 2 8 2 3 8 0 2
35. 35. Decimal to Hexadecimal <ul><li>Technique </li></ul><ul><ul><li>Divide by 16 </li></ul></ul><ul><ul><li>Keep track of the remainder </li></ul></ul>
36. 36. Example 1234 10 = ? 16 1234 10 = 4D2 16 16 1234 77 2 16 4 13 = D 16 0 4
37. 37. Binary to Octal Hexadecimal Decimal Octal Binary
38. 38. Binary to Octal <ul><li>Technique </li></ul><ul><ul><li>Group bits in threes, starting on right </li></ul></ul><ul><ul><li>Convert to octal digits </li></ul></ul>
39. 39. Example 1011010111 2 = ? 8 1011010111 2 = 1327 8 1 011 010 111 1 3 2 7
41. 41. Binary to Hexadecimal <ul><li>Technique </li></ul><ul><ul><li>Group bits in fours, starting on right </li></ul></ul><ul><ul><li>Convert to hexadecimal digits </li></ul></ul>
42. 42. Example 1010111011 2 = ? 16 <ul><li>10 1011 1011 </li></ul><ul><li>B B </li></ul>1010111011 2 = 2BB 16
44. 44. Octal to Hexadecimal <ul><li>Technique </li></ul><ul><ul><li>Use binary as an intermediary </li></ul></ul>
45. 45. Example 1076 8 = ? 16 1076 8 = 23E 16 1 0 7 6 001 000 111 110 2 3 E
47. 47. Hexadecimal to Octal <ul><li>Technique </li></ul><ul><ul><li>Use binary as an intermediary </li></ul></ul>
48. 48. Example 1F0C 16 = ? 8 1F0C 16 = 17414 8 1 F 0 C 0001 1111 0000 1100 1 7 4 1 4
49. 49. Exercise – Convert ... Skip answer Answer Don ’ t use a calculator! Decimal Binary Octal Hexa- decimal 33 1110101 703 1AF
50. 50. Exercise – Convert … Answer Decimal Binary Octal Hexa- decimal 33 100001 41 21 117 1110101 165 75 451 111000011 703 1C3 431 110101111 657 1AF
51. 51. Common Powers (1 of 2) <ul><li>Base 10 </li></ul>Power Preface Symbol 10 -12 pico p 10 -9 nano n 10 -6 micro  10 -3 milli m 10 3 kilo k 10 6 mega M 10 9 giga G 10 12 tera T Value .000000000001 .000000001 .000001 .001 1000 1000000 1000000000 1000000000000
52. 52. Common Powers (2 of 2) <ul><li>Base 2 </li></ul><ul><li>What is the value of “ k ” , “ M ” , and “ G ” ? </li></ul><ul><li>In computing, particularly w.r.t. memory , the base-2 interpretation generally applies </li></ul>Power Preface Symbol 2 10 kilo k 2 20 mega M 2 30 Giga G Value 1024 1048576 1073741824
53. 53. Example In the lab… 1. Double click on My Computer 2. Right click on C: 3. Click on Properties / 2 30 =
54. 54. Exercise – Free Space <ul><li>Determine the “ free space ” on all drives on a machine in the lab </li></ul>Drive Free space Bytes GB A: C: D: E: etc.
55. 55. Review – multiplying powers <ul><li>For common bases, add powers </li></ul>2 6  2 10 = 2 16 = 65,536 or… 2 6  2 10 = 64  2 10 = 64k a b  a c = a b+c
56. 56. Binary Addition (1 of 2) <ul><li>Two 1-bit values </li></ul>pp. 36-38 “ two ” A B A + B 0 0 0 0 1 1 1 0 1 1 1 10
57. 57. Binary Addition (2 of 2) <ul><li>Two n -bit values </li></ul><ul><ul><li>Add individual bits </li></ul></ul><ul><ul><li>Propagate carries </li></ul></ul><ul><ul><li>E.g., </li></ul></ul>10101 21 + 11001 + 25 101110 46 1 1
58. 58. Multiplication (1 of 3) <ul><li>Decimal (just for fun) </li></ul>pp. 39 35 x 105 175 000 35 3675
59. 59. Multiplication (2 of 3) <ul><li>Binary, two 1-bit values </li></ul>A B A  B 0 0 0 0 1 0 1 0 0 1 1 1
60. 60. Multiplication (3 of 3) <ul><li>Binary, two n -bit values </li></ul><ul><ul><li>As with decimal values </li></ul></ul><ul><ul><li>E.g., </li></ul></ul>1110 x 1011 1110 1110 0000 1110 10011010
61. 61. Fractions <ul><li>Decimal to decimal (just for fun) </li></ul>pp. 46-50 3.14 => 4 x 10 -2 = 0.04 1 x 10 -1 = 0.1 3 x 10 0 = 3 3.14
62. 62. Fractions <ul><li>Binary to decimal </li></ul>pp. 46-50 10.1011 => 1 x 2 -4 = 0.0625 1 x 2 -3 = 0.125 0 x 2 -2 = 0.0 1 x 2 -1 = 0.5 0 x 2 0 = 0.0 1 x 2 1 = 2.0 2.6875
63. 63. Fractions <ul><li>Decimal to binary </li></ul>p. 50 3.14579 .14579 x 2 0.29158 x 2 0.58316 x 2 1.16632 x 2 0.33264 x 2 0.66528 x 2 1.33056 etc. 11.001001...
64. 64. Exercise – Convert ... Skip answer Answer Don ’ t use a calculator! Decimal Binary Octal Hexa- decimal 29.8 101.1101 3.07 C.82
65. 65. Exercise – Convert … Answer Decimal Binary Octal Hexa- decimal 29.8 11101.110011… 35.63… 1D.CC… 5.8125 101.1101 5.64 5.D 3.109375 11.000111 3.07 3.1C 12.5078125 1100.10000010 14.404 C.82
66. 66. Thank you Next topic