lecture 6 Flashcards
information encoding
machine language
binary numbers only
binary encoding
convert data into different form or representation
base-10
decimal numbers
0-9
base-2
binary
0-1
base-16
hexidecimal
0-9, A-F
base-10 equation
v = Σ (10^i)(d)
*key:
v –> base-10 value
i –> digit position (increases right
to left starting @ 0)
d –> decimal digit
what is each base-10 digit multiplied by?
power of 10
base-10 example)
173
1 7 3
= 173
how is this equal to 173?
1 7 3
10^2 + 10^1 + 10^0
= 1(10^2) + 7(10^1) + 3(10^0)
= 173
base-2 equation
v = Σ 2^i bi
*key:
v –> base-2 number
i –> digit position (increasing
from right to left, starting @
0)
b –> binary digit (either 1 or 0)
what is each base-2 digit multiplied by?
power of 2
base-2 example)
011111010000
= 2000 (base-10)
how is this equal to 2000?
0 1 0 0 1 0 0 1
2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0
= 1(2^6) + 1(2^3) + 1(2^0)
= 64 +8 +1
= 73
what is the most significant bit?
msb –> always going to be the greatest power of 2
(right most bit)
what is the least significant bit?
lsb –> always going to be the lowest power of 2
(left most bit)
0 1 0 0 1 0 0 1
2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0
what is the msb?
2^7
- greatest power of 2 (right most bit)
0 1 0 0 1 0 0 1
2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0
what is the lsb?
2^0
- least power of 2 (left most bit)
**always going to be 2^0
decimal to binary algorithm
v/2 = quotient, remainder = bit (going to be 0 or 1)
quotient/2, remainder = next bit (going to be 0 or 1)
STEPS:
divide v by 2
remainder becomes next bit
quotient becomes next v
**repeat until v = 0
- msb –> last bit found when v
= 0
- lsb –> first bit found
* first division –> remainder = lsb
* last division –> remainder = msb
base-16 equation
v = Σ 16^i d
*key:
v –> base-10 value
i –> digit position (increasing from
right to left, starting @ 0)
d –> hexit
base-16 0-9 chart
0 - 0
1 - 1
2 - 2
3 - 3
4 - 4
5 - 5
6 - 6
7 - 7
8 - 8
9 - 9
base-16 A-F chart
10 - A
11 - B
12 - C
13 - D
14 - E
15 - F
what is each base-16 digit multiplied by?
power of 16
how many bits is one hexit digit?
4 bits
if you are converting binary to hexit, how do you go about doing this?
break up the binary digits every 4 digits starting at the lsb (leftmost bit)
- in each of these segments, the
digits’ indexes are from 2^0 to
2^3
- do the usual calculation and that’s
the hexit representation
binary to hexit example)
011111010000
= 0x7D
how does this work?
011111010000
A) break up the binary into groups of 4
0111 1101 0000
B) calculate what number each 4 digits add up to
0000 = 0
1 1 0 1
2^3. 2^2. 2^1. 2^0
= 8 + 4 + 1
= 13 –> D
0 1 1 1
2^3. 2^2. 2^1. 2^0
= 4 + 2 + 1
= 7
C) put it together
011111010000 = 0x7D
ASCII encoding allows what
conversion from character to number