Leksioni1 Final2023 - Elementet e Informatikes - Bojken Shehu
Leksioni1 Final2023 - Elementet e Informatikes - Bojken Shehu
Bojken Shehu, Dr
Polytechnic University of Tirana
Faculty of Information Technology
email: bojken.shehu@gmail.com
https://www.youtube.com/@BojkenShehuAcademy
Computer Number Systems, Conversion Techniques.
Conversion Techniques Computer Number Systems Action in All Bases
Binary Number System(2) Binary Number System(2)
Binary to Octal, Introduction to Number Systems Binary Addition,
Binary to Decimal, Binary Subtraction,
Binary to Hexadecimal, Mathematical Interpretation Binary Multiplication,
Binary to other Bases Binary Division
Octal Number System(8) Octal Number System(8)
Octal to Binary,
The Four Most Common Octal Addition,
Octal to Decimal, Number Systems. Octal Subtraction,
Octal Hexadecimal, Octal Multiplication,
Octal to other Bases Binary Number System (base 2) Octal Division
Decimal Number System(10) Octal Number System (base 8) Decimal Number System(10)
Decimal to Binary, Decimal Addition,
Decimal to Octal, Decimal Number System (base10) Decimal Subtraction,
Decimal to Hexadecimal, Decimal Multiplication,
Decimal to other Bases Hexadecimal Number System (base16) Decimal Division
face value Number systems define a set of Now the most important thing: if
values used to represent quantity. you concentrate on the value of this
Digits – Atomic component of particular number, somebody may
2 3 4 5(10) say is 23 hundreds + 45, or
any number system.
Numbers are made from digits. somebody may even say 234 tens +
place value In total 10 digits are available. 5, or 2 thousands and 345.
If you focused at the number, every
place has a particular value.
1000 place value x 2 face value = 2000
https://www.youtube.com/@BojkenShehuAcademy
100 place value x 3 face value = 300
10 place value x 4 face value = 40 After this, we should be worried about, how did
1 place value x 5 face value = 5 this place value come? If we change the base, how
2345 the place value will change?
Value = ∑ face value x place value We need to apply a very general principle.
face value
Place Value = Base to the power 0, starting always from the right side,
because it is a unit place, and the right most place value will always be
2 3 4 5(b) base to the power zero, than every subsequent place value will be
increasing the power of base by 1.
place value
face value
2345(10) = 2000+300+40+5
3 2 1 0
2 3 4 5(10)
= 2x10+3x10+4x10+5x10
2345(8) = 1024+192+32+5
3 2 1 0
place value
= 2x8+3x8+4x8+5x8
= 1253(10)
https://www.youtube.com/@BojkenShehuAcademy
https://www.youtube.com/@BojkenShehuAcademy
https://www.youtube.com/@BojkenShehuAcademy
Converting from smaller base to Compaction The target number is less than the original
larger base. number.
Converting from larger base to Expansion The target number is larger than the
smaller base. original number.
https://www.youtube.com/@BojkenShehuAcademy
For example: 2345(6) = 569(10)
2345(7) = 866(10)
Less than 10
2345(8) = 1253(10) ?
2345(9) = 1742(10)
2345(10) = 2345(10)
2345(11) = 3074(10)
Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 8
Mathematical Interpretation.
2345(6) = 569(10) a(x) = b(y)
2345(7) = 866(10)
Less than 10 x==y a=b
2345(8) = 1253(10)
x>y a<b or b>a
2345(9) = 1742(10)
x<y b<a or a>b
2345(10) = 2345(10)
https://www.youtube.com/@BojkenShehuAcademy
2345(11) = 3074(10)
Expansion method:
2345(10) = 2000+300+40+5
Expansion method 3 2 1 0
Number in Decimal = 2x10+3x10+4x10+5x10
base x system base 10
Division method 2345(8) = 1024+192+32+5
3 2 1 0
= 2x8+3x8+4x8+5x8
Value of number in decimal = ∑face value x place value =1253(10)
Very important point – When base b1<b2 increases, the digits required to represent the quantity
decreases N1>=N2.
For example:
b1<b2 N1>=N2
11100011(2) → 227(10)
16340(8) → 7392(10)
7392(10) → 1CE0(16) https://www.youtube.com/@BojkenShehuAcademy
In computer science, apart from the decimal system, three additional number systems are commonly
used: binary (base-2), octal (base-8), and hexadecimal or just hex (base-16). Binary numbers are
important because that is how numbers are stored in the computer. Octal and hexadecimal are used to
represent binary numbers in a user-friendly way. Each octal symbol represents 3 binary bits and each
hex digit represents 4 binary bits. https://www.youtube.com/@BojkenShehuAcademy
Base(b) Name How many digits? Which digits?
2 Binar 2 0 to (b-1)=[0,1]
8 Octal 8 0 to (b-1)=[0,1,2,3,4,5,6,7]
10 Decimal 10 0 to (b-1)=[0,1,2,3,4,5,6,7,8,9]
16 Hexadecimal 16 0 to (b-1)=[0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F]
By default, Without a base or explicit context, it's assumed that a number is in base 10.
Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 11
Binary Number System.
face value
Base (b)=2 Value of number in decimal=∑ face value x place value
Digits = 0 to (b-1) https://www.youtube.com/@BojkenShehuAcademy
1 0 1 0 1(b) = 0 to (2-1)
4 3 2 1 0
= 0 and 1 10101(2) = 1x2+0x2+1x2+0x2+1x2
place value = 1x16+0x8+1x4+0x2+1x1
Binary digits (0 and 1) = 16+0+4+0+1
are called as bits. = 21(10)
face value
4 3 2 1 0 -1 -2
1 0 1 0 1(2) 10101.11(2) =1x2+0x2+1x2+0x2+1x2+1x2+1x2
= 1x16+0x8+1x4+0x2+1x1+1x1/2+1x1/4
= 16+0+4+0+1+1/2+1/4
place value = 21.75(10)
0001 1
100110111(2)
Converting from Binary (base-2) to 0010 2
0011 3
Hexadecimal (base-16). base 2 0001 0011 0111 0100 4
0101 5
1000 8
group, add 0’s after MSB (left side to
MSB) to form 4 bit group. 100110111(2) =137(16) 1001 9
1010 A
1101 D
111001111(2) = __(16)
1110 E
1111(2) =__(16)
https://www.youtube.com/@BojkenShehuAcademy 1111 F
Converting from Octal (base-8) to Octal Number Position ∑ face value x place value
Decimal (base-10). LSB 2 Position =0
7 Position =1
1. Starting from LSB, multiply each
n MSB 1 Position =2
positional value with 8 when n is
position.
2. Add all the results. 172(8) =122(10) Homework:
757(8) = __(10)
https://www.youtube.com/@BojkenShehuAcademy 231(8) =__(10)
convert to convert to
Base 8 Base 10 Base 16
121(8) = 81(10) 81(10) = 51(16)
Case 2: Converting from Octal (base 8) to 1)
2 1 0
121(8) = 1x8+2x8+1x8
Hexadecimal (base 16).
= 1x64+2x8+1x1
1. Convert Octal (base 8) to Decimal (base 10). = 64+16+1
2. Convert Decimal (base 10) to Hexadecimal 2) = 81(10)
(base 16). Number Division Reminder
81/16 5 1
2. Continue the division in the integer part till you get the number which is less than base and in
the fractional part till you get the number 0.
3. Collect the digits from bottom to top in the integer part and from top to bottom in the
fractional part.
https://www.youtube.com/@BojkenShehuAcademy
2. Continue the division in the integer part till you get the number which is less than base (8)
and in the fractional part till you get the number 0.
3. Collect the digits from bottom to top in the integer part and from top to bottom in the
fractional part.
https://www.youtube.com/@BojkenShehuAcademy
Method 1: Continue the division till you Method 2: Continue the division till you
get the number which is less than base. get the division 0.
Number Division Reminder Number Division Reminder
45/16 2 13 (D) 45/16 2 13 (D)
2/16 0 2
254(10) =FE(16)
https://www.youtube.com/@BojkenShehuAcademy
Division method:
1. Divide the integer part by base (16), and multiply the fractional part by base (16).
2. Continue the division in the integer part till you get the number which is less than base (16)
and in the fractional part till you get the number 0.
3. Collect the digits from bottom to top in the integer part and from top to bottom in the
fractional part. https://www.youtube.com/@BojkenShehuAcademy
Expansion method
Decimal
Number in
system
base x
base 10
Division method
Division method:
1. Divide the integer part by base. Homework:
2. Continue the division till you get the number which is less than base or till 204(10) = __(16)
you get the division 0. 82(10) =__(16)
59(10) =__(16)
3. Collect the digits from bottom to top.
https://www.youtube.com/@BojkenShehuAcademy
2
Example 24: 144(10) = X(12) 12 = 144 1 0 0
12 2 12 1 12 0
Example 25: 729(10) = X(9) 9 3 = 729 1 0 0 0
93 92 91 90
Example 26: 1331(10) = X(11) 11 3 = 1331 1 0 0 0
https://www.youtube.com/@BojkenShehuAcademy 113 11 2 11 1 11 0
Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 41
Converting from Hexadecimal Number System to Other
Number System.
Conversion Techniques
Binary Number System(2) Converting from hexadecimal number system to other number systems.
Binary to Octal,
Binary to Decimal,
Binary to Hexadecimal,
Binary to other Bases Hexadecimal Number System (base 16)
Octal Number System(8)
Octal to Binary, Group by 4 bits
Octal to Decimal,
Hexadecimal to Binary Number System (base 2)
Octal Hexadecimal, Through base 2
Octal to other Bases or base 10
Hexadecimal to Octal Number System (base 8)
Decimal Number System(10)
Decimal to Binary, Expansion method
Decimal to Octal, Hexadecimal to Decimal Number System (base 10)
Decimal to Hexadecimal,
Decimal to other Bases
Depends
Hexadecimal Number System(16)
Hexadecimal to other Number Systems
Hexadecimal to Binary,
Hexadecimal to Octal,
Hexadecimal to Decimal,
Hexadecimal to other bases https://www.youtube.com/@BojkenShehuAcademy
0001 1
0010 2
convert to
Base 16 Base 2 0011 3
0100 4
0110 6
0111 7
base 16 9 2 F
1000 8
1001 9
1011 B
1101 D
1110 E
Division method
Converting from Hexadecimal (base- Octal Number Position ∑ face value x place value
16) to Decimal (base-10). LSB F Position =0
7 Position =1
1. Starting from LSB, multiply each MSB 1 Position =2
n
positional value with 16 when n is
position.
17F(16) =383(10) Homework:
2. Add all the results. 757(16) = __(10)
A31(16) =__(10)
https://www.youtube.com/@BojkenShehuAcademy
https://www.youtube.com/@BojkenShehuAcademy
bojken.shehu@gmail.com