Motivation

Why do we even use Hexadecimal Number System (Base 16)?

Problem: Relationship between two systems are non-trivial

→ 135 (base 10) = 1000 0111 (base 2)

On the other hand, Hexadecimal and Binary systems have an intuitive relationship

→ Base 16 = Base 2^4

Plus, larger values can be represented with shorter strings


Representation

mapping:

0 → 0 1 → 1 2 → 2 3 → 3 4 → 4 5 → 5 6 → 6 7 → 7 8 → 8 9 → 9 A → 10 B → 11 C → 12 D → 13 E → 14 F → 15

ex) 0xE2 → 0x at the front indicates that this is a hexadecimal number,

E and 2 each represent 14 and 2

(16 ^ 1) * 14 + (16 ^ 0) * 2 = 16 * 14 + 1 * 2 = 224 + 2 = 226


Decimal to Hexadecimal

  1. Divide base 10 value by 16
  2. append remainder at the right-end