...
Counting in binary is similar to counting in decimal, except there are only 2 digits. Here's how to count from 0 to 32 in binary.
Number (decimal) | Binary |
---|
0 | 0b000000 |
1 | 0b000001 |
2 | 0b000010 |
3 | 0b000011 |
4 | 0b000100 |
5 | 0b000101 |
6 | 0b000110 |
7 | 0b000111 |
8 | 0b001000 |
9 | 0b001001 |
10 | 0b001010 |
11 | 0b001011 |
12 | 0b001100 |
13 | 0b001101 |
14 | 0b001110 |
15 | 0b001111 |
16 | 0b010000 |
17 | 0b010001 |
18 | 0b010010 |
19 | 0b010011 |
20 | 0b010100 |
21 | 0b010101 |
22 | 0b010110 |
23 | 0b010111 |
24 | 0b011000 |
25 | 0b011001 |
26 | 0b011010 |
27 | 0b011011 |
28 | 0b011100 |
29 | 0b011101 |
30 | 0b011110 |
31 | 0b011111 |
32 | 0b10000 |
...
can be represented as
Mathinline |
---|
body | (15 6 \cdot 16^{1}) + (4 \cdot 16^{0}) |
---|
|
or
Code Block |
---|
language | cpp |
---|
|
0xF0x64 |
Example 3
The number
Code Block |
---|
language | cpp |
---|
|
24140 |
can be represented as
Mathinline |
---|
body | (1 8 \cdot 16^{1}) + (1 12 \cdot 16^{0}) |
---|
|
or
Code Block |
---|
language | cpp |
---|
|
0x180x8C |
Example 4
The number
...
Counting in hex is similar to counting in decimal, except there are an additional 6 digits. Here's how to count from 0 to 32 in hex.
Number (decimal) | Hex |
---|
0 | 0x00 |
1 | 0x01 |
2 | 0x02 |
3 | 0x03 |
4 | 0x04 |
5 | 0x05 |
6 | 0x06 |
7 | 0x07 |
8 | 0x08 |
9 | 0x09 |
10 | 0x0A |
11 | 0x0B |
12 | 0x0C |
13 | 0x0D |
14 | 0x0E |
15 | 0x0F |
16 | 0x10 |
17 | 0x11 |
18 | 0x12 |
19 | 0x13 |
20 | 0x14 |
21 | 0x15 |
22 | 0x16 |
23 | 0x17 |
24 | 0x18 |
25 | 0x19 |
26 | 0x1A |
27 | 0x1B |
28 | 0x1C |
29 | 0x1D |
30 | 0x1E |
31 | 0x1F |
32 | 0x20 |
...