Colors are
numbers not text. They just happen to be presented in hexa
decimal (base 16) instead of decimal (base 10) most of the time because that's easier to read; each color component (red, green, blue and alpha) fits in two hexadecimal digits. There just aren't enough digits to go beyond 9 so letters are used instead.
Decimal | Hexadecimal |
0 | 0 |
1 | 1 |
2 | 2 |
3 | 3 |
4 | 4 |
5 | 5 |
6 | 6 |
7 | 7 |
8 | 8 |
9 | 9 |
10 | A |
11 | B |
12 | C |
13 | D |
14 | E |
15 | F |
In every other regard it works the same way as any decimal number. Once you run out of digits you roll over and you add another digit. So in decimal when you reach 9 you roll over and add another digit so it becomes 10. In hexadecimal when you reach 0xF you roll over and add another digit so it becomes 0x10 (= 16, see below).
For example, in decimal:
Код:
236
= 6 * 10^0 + 3 * 10^1 + 2 * 10^2
= 6 * 1 + 3 * 10 + 2 * 100
= 6 + 30 + 200
= 236
In hexadecimal:
Код:
EC
= C * 16^0 + E * 16^1
= C * 1 + E * 16
= 12 * 1 + 14 * 16
= 12 + 224
= 236
Use sscanf with "x" specifier if it's supposed to be a hexa
decimal input. There's not enough context here to give a more detailed answer.