Professional Documents
Culture Documents
conversions
ENP/classes préparatoires/1ère
année/informatique 1
Djaafri
Introduction : Decimal system
2 1 0
185 (10) = 100 + 80 + 5
= 1 × 100 + 8 × 10 + 5 × 1
2 1 0
= 1 × 10 + 8 × 10 + 5 × 10
Principle
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
.. .. ..
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
• Example
101101100110110011=(?)16
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
• Example
1011011001101100112= (?)8
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
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
1
0 0 1 1 1..
+ + + + +
0 1 0 1 1..
---- ---- ---- ---- ----
=0 =1 =1 =10 =11
carry
+ 1 0 1 1 1
= 1 0 0 0 1 0 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