[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Hex numbers are primarily used as a shorthand for the binary numbers that
computers work with. Every hex digit represents 4 bits of binary
information. (See Figure B-2.) In the binary (base 2) numbering system, a
4-bit number can have 16 different combinations, so the only way to
represent each of the 4-bit binary numbers with a single digit is to use a
base-16 numbering system. (See Figure B-3.)
When you're using 2-byte words, remember the reverse, or "back-words,"
order in which they are stored in memory. See Chapter 2, page 24.
Hex Bits
--------------------------------------------------------------------------
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
A 1010
B 1011
C 1100
D 1101
E 1110
F 1111
--------------------------------------------------------------------------
Figure B-2. The bit patterns for each of the 16 hex digits.
Value
Bit Word Byte Dec Hex
--------------------------------------------------------------------------
0 . . . . . . . . . . . . . . . 1 . . . . . . . 1 1 01H
1 . . . . . . . . . . . . . . 1 . . . . . . . 1 . 2 02H
2 . . . . . . . . . . . . . 1 . . . . . . . 1 . . 4 04H
3 . . . . . . . . . . . . 1 . . . . . . . 1 . . . 8 08H
4 . . . . . . . . . . . 1 . . . . . . . 1 . . . . 16 10H
5 . . . . . . . . . . 1 . . . . . . . 1 . . . . . 32 20H
6 . . . . . . . . . 1 . . . . . . . 1 . . . . . . 64 40H
7 . . . . . . . . 1 . . . . . . . 1 . . . . . . . 128 80H
8 . . . . . . . 1 . . . . . . . . 256 100H
9 . . . . . . 1 . . . . . . . . . 512 200H
10 . . . . . 1 . . . . . . . . . . 1024 400H
11 . . . . 1 . . . . . . . . . . . 2048 800H
12 . . . 1 . . . . . . . . . . . . 4096 1000H
13 . . 1 . . . . . . . . . . . . . 8192 2000H
14 . 1 . . . . . . . . . . . . . . 16,384 4000H
15 1 . . . . . . . . . . . . . . . 32,768 8000H
--------------------------------------------------------------------------
Figure B-3. The hexadecimal and decimal equivalents of each bit in a byte
and each bit in a 2-byte word.
Online resources provided by: http://www.ClipX.Net --- NG 2 HTML conversion by Dave Pearson