Download presentation
Presentation is loading. Please wait.
Published byCornelius Watkins Modified over 8 years ago
1
UMBC CMSC 104 – Section 01, Fall 2016 1
2
UMBC CMSC 104, Section 01 - Fall 2016 Nothing. Enjoy your weekend! 2
3
UMBC CMSC 104, Section 01 - Fall 2016 I want to try something different with this class… Everyone log off your PC and put away your phones/calculators/electronic devices! Break out some paper and a pen/pencil We will be done the slides quickly. I will put up some conversion “problems” at the end to test your understanding. We’re all adults here – if you need more help, you can stay. If it “clicks”, you can go. Don’t be concerned if it doesn’t “click” right away. Stick around. 3
4
UMBC CMSC 104, Section 01 - Fall 2016 4 A bit is a single binary digit (a 1 or 0). A byte is 8 bits A word is 32 bits or 4 bytes Long word = 8 bytes = 64 bits Quad word = 16 bytes = 128 bits Programming languages use these standard number of bits when organizing data storage and access.
5
UMBC CMSC 104, Section 01 - Fall 2016 5 The on and off states of the capacitors in RAM can be thought of as the values 1 and 0, respectively. Therefore, thinking about how information is stored in RAM requires knowledge of the binary (base 2) number system. Let’s review the decimal (base 10) number system first.
6
UMBC CMSC 104, Section 01 - Fall 2016 6 The decimal number system is a positional number system. Example: 5 6 2 1. 44 X 10 -1 =. 4 10 3 10 2 10 1 10 0 10 -1 1 X 10 0 = 1 2 X 10 1 = 20 6 X 10 2 = 600 5 X 10 3 = 5000
7
UMBC CMSC 104, Section 01 - Fall 2016 The decimal number system is also known as base 10. The values of the positions are calculated by taking 10 to some power. Why is the base 10 for decimal numbers? Because we use 10 digits, the digits 0 through 9. 7
8
UMBC CMSC 104, Section 01 - Fall 2016 The binary number system is also known as base 2. The values of the positions are calculated by taking 2 to some power. Why is the base 2 for binary numbers? Because we use 2 digits, the digits 0 and 1. 8
9
UMBC CMSC 104, Section 01 - Fall 2016 9 The binary number system is also a positional numbering system. Instead of using ten digits, 0 - 9, the binary system uses only two digits, 0 and 1. Example of a binary number and the values of the positions: 1 0 0 1 1 0 1 2 6 2 5 2 4 2 3 2 2 2 1 2 0 ?
10
UMBC CMSC 104, Section 01 - Fall 2016 10 1 0 0 1 1 0 11 X 2 0 = 1 2 6 2 5 2 4 2 3 2 2 2 1 2 0 0 X 2 1 = 0 1 X 2 2 = 4 2 0 = 1 2 4 = 16 1 X 2 3 = 8 2 1 = 2 2 5 = 32 0 X 2 4 = 0 2 2 = 4 2 6 = 64 0 X 2 5 = 0 2 3 = 81 X 2 6 = 64 77 10
11
UMBC CMSC 104, Section 01 - Fall 2016 11 Practice conversions: Binary Decimal 11101 1010101 100111 ?
12
UMBC CMSC 104, Section 01 - Fall 2016 12 Make a list of the binary place values up to the number being converted. Perform successive divisions by 2, placing the remainder of 0 or 1 in each of the positions from right to left. Continue until the quotient is zero. Example:42 10 2 5 2 4 2 3 2 2 2 1 2 0 32 16 8 4 2 1 1 0 1 0 1 0
13
UMBC CMSC 104, Section 01 - Fall 2016 13 Practice conversions: Decimal Binary 59 82 175
14
UMBC CMSC 104, Section 01 - Fall 2016 14 0 1 0 1 0 0 0 0 1 0 1 0 0 1 1 1 = ? Humans can’t work well with binary numbers; there are too many digits to deal with. Memory addresses and other data can be quite large. Therefore, we sometimes use the hexadecimal number system.
15
UMBC CMSC 104, Section 01 - Fall 2016 15 The hexadecimal number system is also known as base 16. The values of the positions are calculated by taking 16 to some power. Why is the base 16 for hexadecimal numbers ? Because we use 16 symbols, the digits 0 through 9 and the letters A through F.
16
UMBC CMSC 104, Section 01 - Fall 2016 16 BinaryDecimalHexadecimal 000 111 1022 1133 10044 10155 11066 11177 100088 100199 101010A 101111B 110012C 110113D 111014E 111115F
17
UMBC CMSC 104, Section 01 - Fall 2016 17 Example of a hexadecimal number and the values of the positions: 3 C 8 B 0 5 1 16 6 16 5 16 4 16 3 16 2 16 1 16 0
18
UMBC CMSC 104, Section 01 - Fall 2016 18 Binary: 1 0 1 0 0 0 0 1 0 1 0 0 1 1 1 2 Decimal: 20647 10 Hexadecimal: 50A7 16 Notice how the number of digits gets smaller as the base increases.
19
UMBC CMSC 104, Section 01 - Fall 2016 Because both Hex and Binary are based on powers of two, converting from Binary to Hex (or Hex to Binary) is simple. Binary: 1 1 1 1 0 1 0 0 1 0 1 1 1 1 0 1 2 Hex F 4 B D 16 19
20
UMBC CMSC 104, Section 01 - Fall 2016 Same principals as before… Try converting this hexadecimal value to decimal 3 A F 9. B 16 B X 16 -1 =.69 16 3 16 2 16 1 16 0 16 -1 9 X 16 0 = 9 F X 16 1 = 240 A X 16 2 = 2560 3 X 16 3 = 12288 15097.69 10 20
21
UMBC CMSC 104, Section 01 - Fall 2016 21 Make a list of the hex place values up to the number being converted. Perform successive divisions by 16, placing the remainder in each of the positions from right to left. Continue until the quotient is zero. Example:347 10 16 2 16 1 16 0 256 16 1 1 5 B
22
UMBC CMSC 104, Section 01 - Fall 2016 The logic we’ve applied goes for any arbitrary number system What would a base 7 number system look like? 5 6 2 1. 4 7 4 X 7 -1 =.57 7 3 7 2 7 1 7 0 7 -1 1 X 7 0 = 1 2 X 7 1 = 14 6 X 7 2 = 294 5 X 7 3 = 1715 2024.57 10 22
23
UMBC CMSC 104, Section 01 - Fall 2016 23
24
UMBC CMSC 104, Section 01 - Fall 2016 From Decimal to Binary 19 89 234 From Binary to Decimal 0001 1101 1001 0110 0111 0001 24
25
UMBC CMSC 104, Section 01 - Fall 2016 From Decimal to Binary 19 = 0001 0011 89 = 0101 1001 234 = 1110 1010 From Binary to Decimal 0001 1101 = 29 1001 0110 = 150 0111 0001 = 113 25
26
UMBC CMSC 104, Section 01 - Fall 2016 From Decimal to Hex 116 516 From Hex to Decimal A7 B0B 26
27
UMBC CMSC 104, Section 01 - Fall 2016 From Decimal to Hex 116 = 74 516 = 204 From Hex to Decimal A7 = 167 B0B = 2827 27
28
28
29
UMBC CMSC 104, Section 01 - Fall 2016 29 2727 2626 2525 2424 23232 2121 2020 1286432168421
30
UMBC CMSC 104, Section 01 - Fall 2016 30 16 3 16 2 16 1 16 0 4096256161
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.