Binary and Hexadecimal explanation and examples
For those of us who need a periodic review of binary and hexadecimal numbers, here is a quick look.
Decimal = Base 10
Binary = Base 2
Hexadecimal = Base 16
(4 Bits) (1 nibble)
Decimal | Binary | Hexadecimal | |
---|---|---|---|
0 | 0000 | 0 | 20 = 1 |
1 | 0001 | 1 | 21 = 2 |
2 | 0010 | 2 | 22 = 4 |
3 | 0011 | 3 | 23 = 8 |
4 | 0100 | 4 | 24 = 16 |
5 | 0110 | 6 | 25 = 32 |
6 | 0110 | 6 | 26 = 64 |
7 | 0111 | 7 | 27 = 128 |
8 | 1000 | 8 | 28 = 256 |
9 | 1001 | 9 | 29 = 512 |
10 | 1010 | A | 210 = 1024 |
11 | 1011 | B | 211 = 2048 |
12 | 1100 | C | 212 = 4096 |
13 | 1101 | D | 213 = 8192 |
14 | 1110 | E | 214 = 16384 |
15 | 1111 | F | 215 = 32768 |
4 bits per nibble, 1 nibble is 1 Hex digit
2 nibbles per byte (8 bits), 1 byte is 2 Hex digits
2 bytes per word (16 bits), 1 word is 4 Hex digits
4321 (Nibble #'s)
xxxx (Hex #)
(4) (3) (2) (1) (Nibble #'s)
xxxx xxxx xxxx xxxx (Bin #)
(15-12)(11-8) (7-4) (3-0) (Bit #'s)
Examples:
Bit 10 = 1:
0000 0100 0000 0000 (Bin)
0400 (Hex)
Bit 10=1, 11=1:
0000 1100 0000 0000 (Bin)
0C00 (Hex)
Bit 10=1, 11=1, 6=1, 1=1:
0000 1100 0100 0010 (Bin)
0C42 (Hex)
Bit 0=1, 1=1, 2=1, 3=1, 4=1, 5=1, 8=1:
0000 0001 0011 1111 (Bin)
013F (Hex)