Download presentation
Presentation is loading. Please wait.
Published byBlaze Francis Modified over 9 years ago
1
REPRESENTING INFORMATION: BINARY, HEX, ASCII C ORRESPONDING R EADING : UDC C HAPTER 2 CMSC 150: Lecture 2
2
Controlling Information Watch Newman on YouTube
3
Inside the Computer: Gates AND Gate Input Wires Output Wire 0 1 0 0's & 1's represent low & high voltage, respectively, on the wires
4
Inside the Computer: Gates
5
Representing Information We need to understand how the 0's and 1's can be used to "control information"
6
The Decimal Number System Deci- (ten) Base is ten first (rightmost) place: ones (i.e., 10 0 ) second place: tens (i.e., 10 1 ) third place: hundreds (i.e., 10 2 ) … Digits available: 0, 1, 2, …, 9 (ten total)
7
Example: your favorite number… 8,675,309
8
The Binary Number System Bi- (two) bicycle, bicentennial, biphenyl Base two first (rightmost) place: ones (i.e., 2 0 ) second place: twos (i.e., 2 1 ) third place: fours (i.e., 2 2 ) … Digits available: 0, 1 (two total)
9
Representing Decimal in Binary Moving right to left, include a "slot" for every power of two <= your decimal number Moving left to right: Put 1 in the slot if that power of two can be subtracted from your total remaining Put 0 in the slot if not Continue until all slots are filled filling to the right with 0's as necessary
10
Example 8,675,309 10 = 100001000101111111101101 2 Fewer available digits in binary: more space required for representation
11
Converting Binary to Decimal For each 1, add the corresponding power of two 1010010111101 2
12
Converting Binary to Decimal For each 1, add the corresponding power of two 1010010111101 2 = 5309 10
13
Now You Get The Joke THERE ARE 10 TYPES OF PEOPLE IN THE WORLD: THOSE WHO CAN COUNT IN BINARY AND THOSE WHO CAN'T
14
Too Much Information?
17
An Alternative to Binary? 100001000101111111101101 2 = 8,675,309 10 100000100101111111101101 2 = 8,544,237 10
18
An Alternative to Binary? 100001000101111111101101 2 = 8,675,309 10 100000100101111111101101 2 = 8,544,237 10
19
An Alternative to Binary? What if this was km to landing?
20
The Hexadecimal Number System Hex- (six) Deci- (ten) Base sixteen first (rightmost) place: ones (i.e., 16 0 ) second place: sixteens (i.e., 16 1 ) third place: two-hundred-fifty-sixes (i.e., 16 2 ) … Digits available: sixteen total 0, 1, 2, …, 9, A, B, C, D, E, F
21
Using Hex Can convert decimal to hex and vice-versa process is similar, but using base 16 and 0-9, A-F Most commonly used as a shorthand for binary Avoid this
22
More About Binary How many different things can you represent using binary: with only one slot (i.e., one bit)? with two slots (i.e., two bits)? with three bits? with n bits?
23
More About Binary How many different things can you represent using binary: with only one slot (i.e., one bit)? 2 with two slots (i.e., two bits)? 2 2 = 4 with three bits? 2 3 = 8 with n bits? 2 n
24
Binary vs. Hex One slot in hex can be one of 16 values 0, 1, 2, …, 9, A, B, C, D, E, F How many bits do you need to represent one hex digit?
25
Binary vs. Hex One slot in hex can be one of 16 values 0, 1, 2, …, 9, A, B, C, D, E, F How many bits do you need to represent one hex digit? 4 bits can represent 2 4 = 16 different values
26
Binary vs. Hex 00000 10001 20010 30011 40100 50101 60110 70111 81000 91001 A1010 B1011 C1100 D1101 E1110 F1111
27
Converting Binary to Hex Moving right to left, group into bits of four Convert each four-group to corresponding hex digit 100001000101111111101101 2
28
Converting Hex to Binary Simply convert each hex digit to four-bit binary equivalent BEEF 16 = 1011 1110 1110 1111 2
29
Representing Different Information So far, everything has been a number What about characters? Punctuation? Idea: put all the characters, punctuation in order assign a unique number to each done! (we know how to represent numbers)
30
Our Idea A: 0 B: 1 C: 2 … Z: 25 a: 26 b: 27 … z: 51 , : 52 . : 53 [space] : 54 …
31
ASCII: American Standard Code for Information Interchange
32
'A' = 65 10 = ??? 2 'q' = 90 10 = ??? 2 '8' = 56 10 = ??? 2
33
ASCII: American Standard Code for Information Interchange 256 total characters… How many bits needed?
34
The Problem with ASCII What about Greek characters? Chinese? UNICODE: use 16 bits How many characters can we represent?
35
The Problem with ASCII What about Greek characters? Chinese? UNICODE: use 16 bits How many characters can we represent? 2 16 = 65,536
36
You Control The Information What is this? 01001101
37
You Control The Information What is this? 01001101 Depends on how you interpret it: 01001101 2 = 77 10 01001101 2 = 'M' 01001101 10 = one million one thousand one hundred and one You must be clear on representation and interpretation
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.