Decimal, Binary, and Hexadecimal
Decimal, Binary, and Hexadecimal
HEXADECIMAL
Decimal Numbering System
Ten symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
(A) 3210
(B) 3410
(C) 710
(D) 2810
(E) 3510
Binary Numbering System
Base 10 Base 8 Base 2
Binary is base 2 0 0 0
1 1 1
• Symbols: 0, 1 2 2 10
Convention: 210 = 102 = 0b10 3
4
3
4
11
100
5 5 101
6 6 110
7 7 111
8 10 1000
9 11 1001
Hints:
• 23 = 8
• 22 = 4
• 21 = 2
• 20 = 1
Converting from Decimal to Binary
Given a decimal number N:
• List increasing powers of 2 from right to left until ≥ N
• From left to right, ask is that (power of 2) ≤ N?
– If YES, put a 1 below and subtract that power from N
– If NO, put a 0 below and keep going