Professional Documents
Culture Documents
1.1 Data Representation: 1.1.2 Hexadecimal Number System
1.1 Data Representation: 1.1.2 Hexadecimal Number System
1 Data representation
1.1.2 Hexadecimal
Page 1 of 7
1.1.2 Hexadecimal
Page 2 of 7
1.1.2 Hexadecimal
4
1
1x4
4
2
0
0x2
0
1
1
1x1
1
8
0
0x8
0
0+4+2+1=7
7
4
1
1x4
4
2
1
1x2
2
1
1
1x1
1
Page 3 of 7
1.1.2 Hexadecimal
16
7
1
5
Notice that 7 in binary is 0111 and that 5 is 0101, put them together and we get 01110101 which is the binary
value of 117 again. So binary and hexadecimal are all related in some way.
FROM HEXADECIMAL TO BINARY AND DENARY:
Hexadecimal number BD stands for 11 lots of 16 and 13 units
= 176 + 13
= 189 (in denary)
Note: B = 11, which in binary = 1011
D = 13, which in binary = 1101
Put them together to get 10111101 = the binary value of 189.
Page 4 of 7
1.1.2 Hexadecimal
The second aspect is closely related: Whenever it is necessary to convert the Hex representation back into the
actual Binary bits, the process is simple enough to be done in your own mind. For example, FAD7 hex is
1111 1010 1101 0111 (F=1111, A=1010, D=1101, 7=0111) in Binary. The reason one might wish to do this is
in order to work with "logical" (AND, OR or XOR) or "bit-oriented" instructions (Bit tests, etc.)
which may make it easier (at times) for a programmer to comprehend.
For example, if you wanted to logically AND the hex number FAD7 with D37E, you might have a difficult
time without first changing these numbers into Binary. If you jot them out in Binary on scratch paper, the task
will be much easier:
FAD7(hex)
D37E(hex)
ANDing gives
Answer (in hex)
1111
1101
1101
1010
0011
0010
1101
0111
0101
0111
1110
0110
Page 5 of 7
1.1.2 Hexadecimal
Soon there were two very typical lines of HTML code being used to create background colors:
(RED)
<font color="#00FF00">GREEN</font>(GREEN)
LIME
FUCHSIA
AQUA
You can now see that YELLOW is really a combination of Red and Green. When you combine Red and Blue
it makes Violet (FUCHSIA), and displaying Green and Blue together causes the eye to see CYAN (AQUA).
Other colors are formed by limiting the intensity of one or more of the three Primary Colors. E.g., cutting the
values for the Green and Blue of Cyan in half gives you the default color for the MS-Windows 98 Desktop
called TEAL (color = "#007F7F" ).
[Note: Although you'll often see the word "Green" as the name for the Primary Color represented by
"#00FF00" above, when it came time to assign the names of colors to HTML "tags" for Netscape's browser,
they ended up calling this color "Lime" and assigned the name Green to half the full value: either "#007F00"
(or "#008000").]
Page 6 of 7
Page 7 of 7