Upcoming SlideShare
×
Like this presentation? Why not share!

Like this? Share it with your network

Share

# 01.number systems

• 2,057 views

• Comment goes here.
Are you sure you want to
Be the first to comment

Total Views
2,057
On Slideshare
2,057
From Embeds
0
Number of Embeds
0

Shares
99
0
Likes
2

No embeds

### Report content

No notes for slide

### Transcript

• 1. 1. Number Systems Chapt. 2 Location in course textbook
• 2. Bit & Byte
• Computer uses the binary system .
• 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 .
• A binary digit is called a  bit . There are two possible states in a bit, usually expressed as 0 and 1.
•
• A series of eight bits strung together makes a  byte , much as 12  makes a dozen.
• With 8 bits, or 8 binary digits, there exist 2^ 8 =256 possible combinations.
• 3. combinations
• The following table shows some of these combinations. (The number enclosed in parentheses represents the decimal equivalent.)
• 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)
• 4. Decimal
•   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:
• Original Number: 1 2 3 4
• | | | |
• How Many Tokens: 1 2 3 4
• Digit/Token Value: 1000 100 10 1
• Value: 1000 + 200 + 30 + 4 = 1234
• or simply, 1*1000 + 2*100 + 3*10 + 4*1 = 1234,
• 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.
• 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. 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. 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. 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. Conversion Among Bases
• The possibilities:
Hexadecimal Decimal Octal Binary pp. 40-46
• 10. Quick Example 25 10 = 11001 2 = 31 8 = 19 16 Base
• 11. Decimal to Decimal (just for fun) Hexadecimal Decimal Octal Binary Next slide…
• 12. 125 10 => 5 x 10 0 = 5 2 x 10 1 = 20 1 x 10 2 = 100 125 Base Weight
• 13. Binary to Decimal Hexadecimal Decimal Octal Binary
• 14. Binary to Decimal
• Technique
• Multiply each bit by 2 n , where n is the “ weight ” of the bit
• The weight is the position of the bit, starting from 0 on the right
• 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. Octal to Decimal Hexadecimal Decimal Octal Binary
• 17. Octal to Decimal
• Technique
• Multiply each bit by 8 n , where n is the “ weight ” of the bit
• The weight is the position of the bit, starting from 0 on the right
• 18. Example 724 8 => 4 x 8 0 = 4 2 x 8 1 = 16 7 x 8 2 = 448 468 10
• Technique
• Multiply each bit by 16 n , where n is the “ weight ” of the bit
• The weight is the position of the bit, starting from 0 on the right
• 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. Decimal to Binary Hexadecimal Decimal Octal Binary
• 23. Decimal to Binary
• Technique
• Divide by two, keep track of the remainder
• First remainder is bit 0 (LSB, least-significant bit)
• Second remainder is bit 1
• Etc.
• 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. Octal to Binary Hexadecimal Decimal Octal Binary
• 26. Octal to Binary
• Technique
• Convert each octal digit to a 3-bit equivalent binary representation
• 27. Example 705 8 = ? 2 705 8 = 111000101 2 7 0 5 111 000 101
• Technique
• Convert each hexadecimal digit to a 4-bit equivalent binary representation
• 30. Example 10AF 16 = ? 2 10AF 16 = 0001000010101111 2 1 0 A F 0001 0000 1010 1111
• 31. Decimal to Octal Hexadecimal Decimal Octal Binary
• 32. Decimal to Octal
• Technique
• Divide by 8
• Keep track of the remainder
• 33. Example 1234 10 = ? 8 8 1234 154 2 1234 10 = 2322 8 8 19 2 8 2 3 8 0 2
• Technique
• Divide by 16
• Keep track of the remainder
• 36. Example 1234 10 = ? 16 1234 10 = 4D2 16 16 1234 77 2 16 4 13 = D 16 0 4
• 37. Binary to Octal Hexadecimal Decimal Octal Binary
• 38. Binary to Octal
• Technique
• Group bits in threes, starting on right
• Convert to octal digits
• 39. Example 1011010111 2 = ? 8 1011010111 2 = 1327 8 1 011 010 111 1 3 2 7
• Technique
• Group bits in fours, starting on right
• 42. Example 1010111011 2 = ? 16
• 10 1011 1011
• B B
1010111011 2 = 2BB 16
• Technique
• Use binary as an intermediary
• 45. Example 1076 8 = ? 16 1076 8 = 23E 16 1 0 7 6 001 000 111 110 2 3 E
• Technique
• Use binary as an intermediary
• 48. Example 1F0C 16 = ? 8 1F0C 16 = 17414 8 1 F 0 C 0001 1111 0000 1100 1 7 4 1 4
• 49. Exercise – Convert ... Skip answer Answer Don ’ t use a calculator! Decimal Binary Octal Hexa- decimal 33 1110101 703 1AF
• 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. Common Powers (1 of 2)
• Base 10
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. Common Powers (2 of 2)
• Base 2
• What is the value of “ k ” , “ M ” , and “ G ” ?
• In computing, particularly w.r.t. memory , the base-2 interpretation generally applies
Power Preface Symbol 2 10 kilo k 2 20 mega M 2 30 Giga G Value 1024 1048576 1073741824
• 53. Example In the lab… 1. Double click on My Computer 2. Right click on C: 3. Click on Properties / 2 30 =
• 54. Exercise – Free Space
• Determine the “ free space ” on all drives on a machine in the lab
Drive Free space Bytes GB A: C: D: E: etc.
• 55. Review – multiplying powers
• For common bases, add powers
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. Binary Addition (1 of 2)
• Two 1-bit values
pp. 36-38 “ two ” A B A + B 0 0 0 0 1 1 1 0 1 1 1 10
• 57. Binary Addition (2 of 2)
• Two n -bit values
• Propagate carries
• E.g.,
10101 21 + 11001 + 25 101110 46 1 1
• 58. Multiplication (1 of 3)
• Decimal (just for fun)
pp. 39 35 x 105 175 000 35 3675
• 59. Multiplication (2 of 3)
• Binary, two 1-bit values
A B A  B 0 0 0 0 1 0 1 0 0 1 1 1
• 60. Multiplication (3 of 3)
• Binary, two n -bit values
• As with decimal values
• E.g.,
1110 x 1011 1110 1110 0000 1110 10011010
• 61. Fractions
• Decimal to decimal (just for fun)
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. Fractions
• Binary to decimal
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. Fractions
• Decimal to binary
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. Exercise – Convert ... Skip answer Answer Don ’ t use a calculator! Decimal Binary Octal Hexa- decimal 29.8 101.1101 3.07 C.82
• 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. Thank you Next topic