Escolar Documentos
Profissional Documentos
Cultura Documentos
Significant Digits
Binary: 11101101
Most significant digit Least significant digit
Hexadecimal: 1D63A7A
Most significant digit Least significant digit
0 1 2 3 4 5 6 7
20 21 22 23 24 25 26 27
1 2 4 8 16 32 64 128
Octal
1 2 3 4 5 6 7 10 11 12 13 14 15 16 17
Decimal
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Binary
0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
Weight
12510 =>
Base
Quick Example
Multiplication Algorithm
Convert (10101101)2 to its decimal equivalent:
1 0 1 0 1 1 0 1 x x x x x x x x
27 26 25 24 23 22 128 + 32 + 8 + 4 + 1 21 20
17310
Binary to Decimal
Technique
Multiply each bit by 2n, where n is the weight of the bit The weight is the position of the bit, starting from 0 on the right Add the results
Example
Bit 0 1 x 20 = 1 x 21 0 x 22 1 x 23 0 x 24 1 x 25
1010112 =>
1 = 2 = 0 = 8 = 0 = 32 4310
Octal to Decimal
Technique
Multiply each bit by 8n, where n is the weight of the bit The weight is the position of the bit, starting from 0 on the right Add the results
6
x
82
Products
81
80
384 + 40 + 3
42710
Example
7248 => 4 x 80 = 2 x 81 = 7 x 82 =
4 16 448 46810
Hexadecimal to Decimal
Technique
Multiply each bit by 16n, where n is the weight of the bit The weight is the position of the bit, starting from 0 on the right Add the results
3
Positional Values x
B
x
F
x
15,18310
Example
ABC16 =>
Exercises
Convert the following to decimal: 1.1001102 2.3E16 3.1416 4.3528 5.4D316 6.3F53A16 7.74738 8.557C16
Binary to Octal
Technique
Group bits in threes, starting on right Convert to octal digits
Substitution Code
Substitution code can also be used to convert binary to octal by using 3-bit groupings: 2 5 5 2 7 1 5 2
255271528
Example
10110101112 = ?8
10110101112 = 13278
Binary to Hexadecimal
Technique
Group bits in fours, starting on right Convert to hexadecimal digits
Substitution Code
Convert 0101011010101110011010102 to hex using the 4-bit substitution code : 5 6 A E 6 A
56AE6A16
Example
10101110112 = ?16
10 1011 1011
10101110112 = 2BB16
Exercises
Convert 11101 to octal Convert 11101 to hexadecimal Convert 100110 to octal Convert 11001100 to hexadecimal _________ _________ _________ _________
Convert Binary to Decimal, Octal and Hexadecimal: 11101101 111100111 10111001 10010110 1111001 11011101 10011110 100010011 101011110 11100001
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.
Division Algorithm
Convert 67 to its binary equivalent:
6710 = x2
Step 1: 67 / 2 = 33 R 1 Step 2: 33 / 2 = 16 R 1 Step 3: 16 / 2 = 8 R 0 Step 4: 8 / 2 = 4 R 0 Step 5: 4 / 2 = 2 R 0 Step 6: 2 / 2 = 1 R 0 Step 7: 1 / 2 = 0 R 1 Divide 67 by 2. Record quotient in next row Again divide by 2; record quotient in next row Repeat again Repeat again Repeat again Repeat again STOP when quotient equals 0
1 0 0 0 0 1 12
Example
12510 = ?2 2 125 2 62 2 2 2 2 2 31 15 7 3 1 0 1 0 1 1 1 1 1
12510 = 11111012
Decimal to Octal
Technique
Divide by 8 Keep track of the remainder
Example
123410 = ?8 8 8 8 8 1234 154 19 2 0
2 2 3 2
123410 = 23228
6538
Decimal to Hexadecimal
Technique
Divide by 16 Keep track of the remainder
= E in Hex
33E16
Example
123410 = ?16 16 16 16 1234 77 4 0
2 13 = D 4
123410 = 4D216
Octal to Binary
Technique
Convert each octal digit to a 3-bit equivalent binary representation
Example
7058 = ?2
7058 = 1110001012
Hexadecimal to Binary
Technique
Convert each hexadecimal digit to a 4-bit equivalent binary representation
Example
10AF16 = ?2
10AF16 = 00010000101011112
Octal to Hexadecimal
Technique
Use binary as an intermediary
Example
1F0C16 = ?8 1 F 0 C
0001
1111
0000
1100
1F0C16 = 174148
Fractions
Decimal to decimal (just for fun)
3.14 => 4 x 10-2 = 0.04 1 x 10-1 = 0.1 3 x 100 = 3 3.14
pp. 46-50
Fractions
Binary to decimal
10.1011 => 1 x 2-4 = 0.0625 1 x 2-3 = 0 x 2-2 = 1 x 2-1 = 0 x 20 = 1 x 21 = 0.125 0.0 0.5 0.0 2.0 2.6875
pp. 46-50
Fractions
Decimal to binary
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. p. 50
11.001001...
Binary Addition
4 Possible Binary Addition Combinations:
(1)
Carry
(3)
0 +0 00 1 +0 01
(2)
Sum
(4)
0 +1 01 1 +1 10
Binary Addition (1 of 2)
Two 1-bit values
A 0 0 1 1 B 0 1 0 1 A+B 0 1 1 10
two pp. 36-38
Binary Addition (2 of 2)
Two n-bit values
Add individual bits Propagate carries E.g.,
1 1
21 + 25 46