Binary Conversion
Binary Representation of Data
In order to work with data, the data must be represented inside the computer. Digital computers represent data by means of an easily identified symbol called a digit.
Numbering Systems
Each number system has a base also called a Radix. A decimal number system is a system of base 10; binary is a system of base 2; octal is a system of base 8; and hexadecimal is a system of base 16. What are these varying bases? The answer lies in what happens when we count up to the maximum number that the numbering system allows. In base 10, we can count from 0 to 9, that is, 10 digits.
Number System
|
Base
|
Symbols used
|
Binary
|
2
|
0,1
|
Octal
|
8
|
0,1,2,3,4,5,6,7,8
|
Decimal
|
10
|
0,1,2,3,4,5,6,7,8,9
|
Hexadecimal
|
16
|
0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
Where A=10,B=11,C=12,D=13,E=14,F=15
|
· Binary Conversion
a) Binary to Decimal
1. Start at the rightmost bit.
2. Take that bit and multiply by 2n where n is the current position beginning at 0 and increasing by 1 each time. This represents a power of two.
3. Sum each terms of product until all bits have been used.
Example
Convert the Binary number 101011 to its Decimal equivalent.
1 * 25 + 0 * 24 + 1 * 23 + 0 * 22 + 1 * 21 + 1 * 20
32 + 0 + 8 + 0 +2 + 1 = (43)10
b) Binary fraction to decimal
Example
Convert (11011.101) to decimal
24
|
23
|
22
|
21
|
20
|
2-1
|
2-2
|
2-3
|
1
|
1
|
0
|
1
|
1
|
1
|
0
|
1
|
= (1 x 24) + (1 x 23) + (0 x 22) + (1 x 21) + (1 x 20) + (1 x 2-1) + (0 x 2-2) + (1 x 2-3)
= 16+8+0+2+1+0.5+0+0.125
= (27.625)10
c) Binary to Octal
For this conversion make the group of three digits from right to left represent each group as an octal digit.
Binary
|
Octal
|
000
|
0
|
001
|
1
|
010
|
2
|
011
|
3
|
100
|
4
|
101
|
5
|
110
|
6
|
111
|
7
|
Example
Convert the Binary Number (111100010)2 to Octal
111 | 100 | 010
7 | 4 | 2
= (742)8
d) Binary Fraction to Octal
For this conversion make the group of three digits from right to left before decimal & left to right after decimal then assign the specific octal value.
Example
Convert the Binary Fraction (110101000.101010)2 to Octal
110|101|000|.|101| |010|
6 | 5 | 0 |.| 5 | | 2 |
= (650.52)8
e) Binary to Hexadecimal
For this conversion make the group of four digits from right to left represent each group as hexadecimal digit.
Binary
|
Hexadecimal
|
0000
|
0
|
0001
|
1
|
0010
|
2
|
0011
|
3
|
0100
|
4
|
0101
|
5
|
0110
|
6
|
0111
|
7
|
1000
|
8
|
1001
|
9
|
1010
|
A
|
1011
|
B
|
1100
|
C
|
1101
|
D
|
1110
|
E
|
1111
|
F
|
Example
Convert Binary Number (1010 0010 1111)2 to Hexadecimal
1010 | 0010 | 1111
A | 2 | F
= (A2F)16
f) Binary Fraction to Hexadecimal
For this conversion make the group of four digits from right to left before decimal & left to right after decimal then assign the specific hexadecimal value.
Example
Convert the Binary fraction (11100.1010)2 to Hexadecimal
0001 | 1100 | . | 1010 |
1 | C | . | A |
= (1CA)16
Comments
Post a Comment