Why Teams call analytics are critical to your entire business
01 intro
1. Binary Numbers
Strings of binary digits (“bits”)
One bit can store a number from 0 to 1
n bits can store numbers from 0 to 2n
1
2. Binary – Powers of 2
Positional representation
Each digit represents a power of 2
So 101 binary is
1 • 22 + 0 • 21 + 1 • 20
or
1•4 + 0•2 + 1•1=5
2
3. Converting Binary to Decimal
Easy, just multiply digit by power of 2
Just like a decimal number is represented
Example follows
3
5. Decimal to Binary
A little more work than binary to decimal
Some examples
3 = 2 + 1 = 11 (that‟s 1•21 + 1•20)
5 = 4 + 1 = 101 (that‟s 1•22 + 0•21 + 1•20)
5
6. Algorithm – Decimal to Binary
Find largest power-of-two smaller than decimal
number
Make the appropriate binary digit a „1‟
Subtract the power of 2 from decimal
Do the same thing again
6
7. Decimal
Binary Example
Convert 28 decimal to binary
32 is too large, so use 16
Binary
10000
Decimal
Next is 8
Binary
11000
Decimal
Next is 4
Binary
11100
Decimal
28 – 16 = 12
12 – 8 = 4
4–4=0
7
6
5
4
3
2
1
0
27
26
25
24
23
22
21
20
128
64
32
16
8
4
2
1
7
8. Hexadecimal
Strings of 0s and 1s too hard to write
Use base-16 or hexadecimal – 4 bits
Dec
Bin
Hex
Dec
Bin
Hex
0
0000
0
8
1000
8
1
0001
1
9
1001
9
2
0010
2
10
1010
?
3
0011
3
11
1011
?
4
0100
4
12
1100
?
5
0101
5
13
1101
?
6
0110
6
14
1110
?
7
0111
7
15
1111
?
8
9. Hexadecimal
Letters to represent 10-15
Dec
Bin
Hex
Dec
Bin
Hex
0
0000
0
8
1000
8
1
0001
1
9
1001
9
2
0010
2
10
1010
a
3
0011
3
11
1011
b
4
0100
4
12
1100
c
5
0101
5
13
1101
d
6
0110
6
14
1110
e
•Power of 2
7
0111
7
15
1111
f
•Size of byte
Why use
base 16?
9
10. Hex to Binary
Bin
Hex
0000
0
0001
1
0010
2
Convention – write 0x before number
0011
3
Hex to Binary – just convert digits
0100
4
0101
5
0110
6
0111
7
1000
8
1001
9
1010
a
1011
b
1100
c
1101
d
1110
e
1111
f
0x2ac
0010
1010 1100
0x2ac = 001010101100
No magic – remember hex digit = 4 bits
10
11. Binary to Hex
Bin
0000
0011
0100
0101
3
7
b
101001101111011 = 0x537b
5
0110
1011
4
6
0111
7
1000
8
9
a
1011
b
1100
c
1101
5
0111
3
1010
0011
2
1001
0101
1
0010
101001101111011
0
0001
Just convert groups of 4 bits
Hex
d
1110
e
1111
f
11
12. Hex to Decimal
Dec
Hex
0
0
Just multiply each hex digit by decimal value,
1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
a
11
b
12
c
13
d
14
e
15
f
and add the results.
0x2ac
2 • 256
+ 10 • 16 + 12 • 1 = 684
163
162
161
160
4096
256
16
1
12
13. Decimal to Hex
1.
2.
3.
4.
Analogous to decimal
binary.
Find largest power-of-16 smaller than decimal
number
Divide by power-of-16. The integer result is hex
digit.
The remainder is new decimal number.
Do the same thing again
13