0% found this document useful (0 votes)
48 views

Decimal, Binary, and Hexadecimal

Decimal, binary, hexadecimal, and octal are different numbering systems that use different sets of symbols to represent values. Decimal uses 0-9, binary uses 0-1, hexadecimal uses 0-9 and A-F, and octal uses 0-7. Being able to convert between these bases allows one to understand how computers store and process numeric data internally using binary.

Uploaded by

Null Point
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
0% found this document useful (0 votes)
48 views

Decimal, Binary, and Hexadecimal

Decimal, binary, hexadecimal, and octal are different numbering systems that use different sets of symbols to represent values. Decimal uses 0-9, binary uses 0-1, hexadecimal uses 0-9 and A-F, and octal uses 0-7. Being able to convert between these bases allows one to understand how computers store and process numeric data internally using binary.

Uploaded by

Null Point
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
You are on page 1/ 15

DECIMAL, BINARY, AND

HEXADECIMAL
Decimal Numbering System
Ten symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Represent larger numbers as a sequence of digits


• Each digit is one of the available symbols

Example: 7061 in decimal (base 10)


• 706110 = (7 x 103) + (0 x 102) + (6 x 101) + (1 x 100)
Octal Numbering System
Eight symbols: : 0, 1, 2, 3, 4, 5, 6, 7
• Notice that we no longer use 8 or 9
Base Comparison:
Base 10: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12…
Base 8: 0, 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 13, 14…

Example: What is 158 in base 10?


• 158 = (1 x 81) + (5 x 80) = 1310
Example: What is 70618 in base 10?
• 70618 = (7 x 83) + (0 x 82) + (6 x 81) + (1 x 80) = 363310
Question
What is 348 in base 10?

(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

Example: What is 0b110 in base 10?


• 0b110 = 1102 = (1 x 22) + (1 x 21) + (0 x 10) = 610
Hexadecimal Number System
Hexadecimal is base 16 (>10)
• Symbols? 0, 1, 2, 3, 4, 5, 6, 7, 8,
8, 9,
9, A,
…?B, C, D, E, F
Convention: 1610 = 1016 = 0x10

Example: What is 0xA5 in base 10?


• 0xA5 = A516 = (10 x 161) + (5 x 160) = 16510
Question
Which of the following orderings is correct?

(A) 0xC < 0b1010 < 11


(B) 0xC < 11 < 0b1010
(C) 11 < 0b1010 < 0xC
(D) 0b1010 < 11 < 0xC
(E) 0b1010 < 0xC < 11
BASE CONVERSION
Converting to Base 10
Can convert from any base to base 10
• 1102 = (1 x 22) + (1 x 21) + (0 x 10) = 610
• 0xA5 = A516 = (10 x 161) + (5 x 160) = 16510

We learned to think in base 10, so this is fairly


natural for us

Challenge: Convert into other bases (e.g. 2, 16)


Challenge Question
Convert 1310 to binary

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

Example for 13: 24=16 23=8 22=4 21=2 20=1


5 0 1 1 0 1
1
0
Converting Binary Hexadecimal
Base 10 Base 16 Base 2
Hex to Binary 0 0 0000
• Substitute hex digits, then drop 1 1 0001
leading zeros 2 2 0010
3 3 0011
• Example: 0x2D in binary 4 4 0100
– 0x2 is 0b0010, 0xD is 0b1101 5 5 0101
– Drop two leading zeros, answer is 0b101101 6 6 0110
7 7 0111
8 8 1000
Binary to Hex 9 9 1001
10 A 1010
• Pad with leading zeros until multiple 11 B 1011
of 4, then substitute groups of 4 12 C 1100
13 D 1101
• Example: 0b101101 14 E 1110
– Pad to 0b 0010 1101 15 F 1111
– Substitute to get 0x2D
Binary Hex Practice
Base 10 Base 16 Base 2
Convert 0b100110110101101 0 0 0000
• How many digits? 15 1 1 0001
2 2 0010
• Pad: 0b 0100 1101 1010 1101 3 3 0011
4 4 0100
• Substitute: 0x4DAD 5 5 0101
6 6 0110
7 7 0111
8 8 1000
9 9 1001
10 A 1010
11 B 1011
12 C 1100
13 D 1101
14 E 1110
15 F 1111
Why are we learning this?
Why does all of this matter?
• Humans think about numbers in base 10 but computers
think about numbers in base 2
• How is it that computers can do all of the amazing
things that they do?
– Binary encodin
Summary

A binary digit is known as a bit.


A group of 4 bits (1 hex digit) is called a nibble
A group of 8 bits (2 hex digits) is called a byte

You might also like