Binary and Hexadecimal |
The CPU works using binary. Electronically this is done with electronic switches
that are either on or off. This is represented on paper by noughts and ones.
A single BIT or binary digit requires one wire or switch within the CPU. Usually
data is handled in BYTES or multiples of bytes. A Byte is a group of eight bits.
A byte looks like this
This is inconvenient to read, say and write down so programmers use hexadecimal to represent bytes. Converting between binary and hexadecimal is not difficult. First split the byte into two nybbles (half a byte) as follows
Then use the following table
BINARY |
HEXADECIMAL |
DECIMAL |
0 0 0 0 |
0 |
0 |
0 0 0 1 |
1 |
1 |
0 0 1 0 |
2 |
2 |
0 0 1 1 |
3 |
3 |
0 1 0 0 |
4 |
4 |
0 1 0 1 |
5 |
5 |
0 1 1 0 |
6 |
6 |
0 1 1 1 |
7 |
7 |
1 0 0 0 |
8 |
8 |
1 0 0 1 |
9 |
9 |
1 0 1 0 |
A |
10 |
1 0 1 1 |
B |
11 |
1 1 0 0 |
C |
12 |
1 1 0 1 |
D |
13 |
1 1 1 0 |
E |
14 |
1 1 1 1 |
F |
15 |
Split the byte into two halves
01001011 becomes 0100 1011
Using the table above
0100 is 4
1011 is B
The answer ...
0100 1011 is 4B in Hexadecimal.
To convert the other way take a hexadecimal such as E7.
Look up E in the table. It is 1110.
Look up 7 in the table. It is 0111.
E7 is 1110 0111.
© C Neil Bauers 2003