0% found this document useful (0 votes)
25 views25 pages

Number Systems and Conversions

This document discusses different number systems including decimal, binary, octal, and hexadecimal. It provides examples of converting between these number systems. The key concepts covered are: - Each number system uses a set of symbols and a base (like 10 for decimal) - To convert from one base to another, you express the number in the target base using the place value of its digits - Binary uses only 0s and 1s, octal uses 0-7, hexadecimal uses 0-9 and A-F - Conversion between bases may require using tables or breaking numbers into place values - Arithmetic can be performed in any base system by following the rules for that base (like binary addition follows different rules than
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views25 pages

Number Systems and Conversions

This document discusses different number systems including decimal, binary, octal, and hexadecimal. It provides examples of converting between these number systems. The key concepts covered are: - Each number system uses a set of symbols and a base (like 10 for decimal) - To convert from one base to another, you express the number in the target base using the place value of its digits - Binary uses only 0s and 1s, octal uses 0-7, hexadecimal uses 0-9 and A-F - Conversion between bases may require using tables or breaking numbers into place values - Arithmetic can be performed in any base system by following the rules for that base (like binary addition follows different rules than
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

Chapter 2: Number systems and

conversions

ENP/classes préparatoires/1ère
année/informatique 1

Djaafri
Introduction : Decimal system

Set of 10 symbols: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}


• Exemple 1: a integer number

2 1 0
185 (10) = 100 + 80 + 5
= 1 × 100 + 8 × 10 + 5 × 1
2 1 0
= 1 × 10 + 8 × 10 + 5 × 10
Principle

• B is base for number system:


▪ B is integer and b>1.
▪ a system uses B sequential integers symbols
including 0
🡺 {0, 1, 2, 3, ..., B-1}
▪ These symbols are called the digits of the
system.
Principle
• Any integer N is represented in base B by a
sequence of digits :
N = an an-1... a2 a1 a0

• In base B, N is also written as:


N = an × Bn + an-1× B n-1 + ... + a2 × B2 + a1 × B1
+ a0 × B0
→ ai is digit in ith position
→ Bi is the base B raised to the power i
Binary number system

Set of 2 symbols: {0, 1}


• Exemple :
3210
3 2 1 0
1101 (2) = 1 × 2 + 1 × 2 + 0 × 2 + 1 × 2
= 8 +4 +0 +1
1101(2) = 13
Binary number system

0 0 9 1001
1 1 10 1010
2 10 11 1011
3 11 12 1100
4 100 13 1101
5 101 14 1110
6 110 15 1111
7 111 16 10000
8 1000 .. ..
Binary number system
1 20 1
10 21 2
100 22 4
1000 23 8
10000 24 16
100000 25 32
1000000 26 64
.. .. ..

10112 = 1000 + 11 = 1000 + 10 + 1


= 8 + 2 +1
= 1110
100102 = 10000 + 10
= 16 + 2
= 1810
Octal number system
Set of 8 symbols: {0, 1, 2, 3, 4, 5, 6, 7}
• Exemple :
2 1 0
2 1 0
613 (8) = 6 × 8 + 1 × 8 + 3 × 8
= 6 × 64 + 1 × 8 + 3 × 1
= 384 +8 +3
613 (8) = 395
Hexadecimal number system

Set of 16 symbols: {0..9, A..F}


• Exemple :
2 1 0
2 1 0
E09 (16) = E × 16 + 0 × 16 + 9 × 16
= 14 × 256 +0 +9
E09 (16) = 3593
Binary, hexa and octal roles
• Binary system is used to treat and stock information
on computer
• Binary representation of information is very verbose,
so hexadecimal and octal numbers system are used
to reduce the binary representation
• Example:
A same value represented in base 2, 8 an 16
binary 101 0110 0000 0111 1011 1101
octal 25403675
hexadecimal 5607BD
Conversion from any base x to decimal
• Method:
1. number each digit from right to left starting from 0
2. Multiply each digit by the base-x raising to the position number
obtained in step 1
3. Sum all values obtained in step 02
• Example
20213 33 32 31 30
2 0 2 1

20213= 2×27 + 0×9 + 2×3 +1×1 =6110


4135 52 51 50
4 1 3

4135 = 4×25 + 1×5 + 3×1 =10810


Conversion from Decimal to any base x
• Method 1
1. Successive division on x
2. Take the remainders from the last to the first
3. Stop when quotient equals 0.
• Example
4410=(?)2
44 ÷ 2 = 22 rem 0
22 ÷ 2 = 11 rem 0
11 ÷ 2 = 5 rem 1
5 ÷2= 2 rem 1
2 ÷2= 1 rem 0
1 ÷2= 0 rem 1

4410= 1011002
Conversion from Decimal to any base x
• Method 2 : need power of x values

• Example
4410=(?)2 25 24 23 22 21 20
32 16 8 4 2 1
1 0 1 1 0 0

44 = 32+8+4
= 1×25 + 0×24 + 1×23 + 1×22 + 0×21 + 0×20

44 10=1011002
binary to Hex & Hex to binary
Need to use a look up table

Decimal Hexadecimal Binary Decimal Hexadecimal Binary


0 0 0000 10 A 1010
1 1 0001 11 B 1011
2 2 0010 12 C 1100
3 3 0011 13 D 1101
4 4 0100 14 E 1110
5 5 0101 15 F 1111
6 6 0110
7 7 0111
8 8 1000
9 9 1001
Conversion from Binary to Hexa
• Method
Replace each 4 binary digits with its hexadecimal equivalent

• Example
101101100110110011=(?)16

0010 1101 1001 1011 0011

2 D 9 B 3

1011011001101100112= 2D9B316
Conversion from Hexa to Binary
• Method
Break up each hexadecimal digit into 4 binary digit. Right to left

• Example
1DF8316 = (?)2

1 D F 8 3

0001 1101 1111 1000 0011


Binary to Octal & Octal to Binary
Need to use a lookup table
Decimal Octal Binary
0 0 000
1 1 001
2 2 010
3 3 011
4 4 100
5 5 101
6 6 110
7 7 111
Conversion from Binary to Octal
• Method
Replace each 3 binary digits with its octal equivalent

• Example
1011011001101100112= (?)8

101 101 100 110 110 011

5 5 4 6 6 3

1011011001101100112= 5546638
Conversion from Octal to Binary
• Method
Break up each octal digit into 3 binary digit. Right to left

• Example
74038 = (?)2

7 4 0 3

111 100 000 011

74038 = 1111000000112
Summary conversion base 2, base 8
and base 16
Binary

Octal Hexa

Example
127038 =(?)16
1→001
2→010
127038 → 7→111 →001 010 111 000 0112
0→000
3→011
0001→1
0101→5
001 0101 1100 0011 → 1100→C
→15C316
0011→3
127038 =15C316
Conversion from Base-x to Base-y
• Method
Use conversion from base-x to Decimal, then from Deciaml to Base-y

• Example
314 5= (?)2
Base-5 to decimal:
3145 = 3×52 + 1×51 + 4×50 = 84
Decimal to base-2
8410 = 64+16+4
= 2 6 + 24 + 22
= 1×26 + 0×25 + 1×24 + 0×23 + 1×22 + 0×21 + 0×20
8410 = 10101002

Then 3145 = 10101002


Arithmetic with binary base system
Rules

1
0 0 1 1 1..
+ + + + +
0 1 0 1 1..
---- ---- ---- ---- ----
=0 =1 =1 =10 =11

carry

• You need know binary values


102 → 2
112 → 3
addition
1 1 1 1 1
1 0 1 1 0 1

+ 1 0 1 1 1

= 1 0 0 0 1 0 0

101101 + 10111 = 1000100


1 1 1 1
1 1 1 1 1 0

+ 1 0 1 1

= 1 0 0 1 0 0 1
111110 + 1011 = 1001001
Substraction
1 10 1 11 10 10

- 1 1 10 11 11 1

= 0 1 0 1 0 1
101100 - 10111 = 10101
1 1 1 1 11 10

- 1 10 11 1

= 1 1 0 0 1 1
101100 - 10111 = 10101
Principle with real number
• Exemple 2: a real number
2 1 0 -1 -2 -3
185,437 in 10 base
=
100 + 80 + 5 + 0,4 + 0,03 + 0,007
=
1 × 102 + 8 × 101 + 5 × 100 + 4 × 10-1 + 3 × 10-2 + 7 × 10-3

You might also like