0% found this document useful (0 votes)
55 views48 pages

Leksioni1 Final2023 - Elementet e Informatikes - Bojken Shehu

Uploaded by

artur kaceli
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)
55 views48 pages

Leksioni1 Final2023 - Elementet e Informatikes - Bojken Shehu

Uploaded by

artur kaceli
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/ 48

Polytechnic University of Tirana

Faculty of Information Technology

Lecture 01: Computer Number Systems, Conversion


Techniques

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

Hexadecimal Number System(16) Hexadecimal Number System(16)


Hexadecimal to Binary, Hexadecimal Addition,
Hexadecimal to Octal, Hexadecimal Subtraction,
Hexadecimal to Decimal, Hexadecimal Multiplication,
Hexadecimal to other bases https://www.youtube.com/@BojkenShehuAcademy Hexadecimal Division

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 2


Byte, Kilobyte, Megabyte, Gigabyte.
 1 Byte (B) = 8 bit (b). Bit is smallest unit of data.
 1 Nibble (half-byte) = 4 bits , For example: BCD and BCH.

 1 word = 16 bits = 2 bytes.


 1 Double word = 32 bits = 4 bytes.
10
 1 Kilobyte (KB): 2 byte = 1024 byte.
For example: 3KB = 3x1024 byte.
20
 1 Megabyte (MB) = 2 byte = 1.048.576 byte.
For example: 3MB = 3x1.048.576 byte.
30
 1 Gigabyte (GB) = 2 byte = 1.073.741.824 byte.
For example: 3x1.073.741.824 byte.
https://www.youtube.com/@BojkenShehuAcademy

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 3


Computer Number Systems.

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.

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 4


Computer Number Systems.

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

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 5


Computer Number Systems.
 How many digits are available and what are the digits which are available?

Base(b) Name How many digits? Which digits?


2 Binary 2 0 to (b-1) = [0,1]
3 Ternary 3 0 to (b-1) = [0,1,2]
4 Quaternary 4 0 to (b-1) = [0,1,2,3]
5 Quinary 5 0 to (b-1) = [0,1,2,3,4]
6 Senary 6 0 to (b-1) = [0,1,2,3,4,5]
7 Septenary 7 0 to (b-1) = [0,1,2,3,4,5,6]
8 Octal 8 0 to (b-1) = [0,1,2,3,4,5,6,7]
9 Nonary 9 0 to (b-1) = [0,1,2,3,4,5,6,7,8]

https://www.youtube.com/@BojkenShehuAcademy

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 6


Computer Number Systems.
 How many digits are available and what are the digits which are available?

Base(b) Name How many digits? Which digits?


10 Decimal 10 0 to (b-1)=[0,1,2,3,4,5,6,7,8,9]
11 Undenary 11 0 to (b-1)=[0,1,2,3,4,5,6,7,8,9,A]
12 Duodecimal 12 0 to (b-1)=[0,1,2,3,4,5,6,7,8,9,A,B]
13 Tridecimal 13 0 to (b-1)=[0,1,2,3,4,5,6,7,8,9,A,B,C]
14 Tetradecimal 14 0 to (b-1)=[0,1,2,3,4,5,6,7,8,9,A,B,C,D]
15 Quindecimal 15 0 to (b-1)=[0,1,2,3,4,5,6,7,8,9,A,B,C,D,E]
16 Hexadecimal 16 0 to (b-1)=[0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F]
17 - - -

https://www.youtube.com/@BojkenShehuAcademy

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 7


Mathematical Interpretation.

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)

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 9


Mathematical Interpretation

 b1- base of number system  b2- base of another number system


16340(8) →7392(10)
 N1- total number of digits required to  N2- total number of digits required
represent this quantity in this number to represent this quantity in another
system. number system.

 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

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 10


The Four Most Common Number Systems.
 A number system is the way we name and represent numbers. The number system we use in our daily
life is known as decimal number system or base 10 because it is based on 10 different digits: 0-9. The
base of number is written as subscript to a number.

 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)

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 12


Binary Number System - MSB and LSB.
 In computing, the most significant bit (MSB), also called the high-order bit, is the bit position in a
binary number having the greatest value.
 In computing, the least significant bit (LSB), is the bit position in a binary number giving the units
value. https://www.youtube.com/@BojkenShehuAcademy

face value Expansion method binary number


Number in Decimal system
1 0 1 0 1
base x base 10
1 0 1 0 1(b) Division method
MSB LSB
Value of number in decimal=∑ face value x place value
place value
4 3 2 1 0
Base (b)=2 10101(2) = 1x2+0x2+1x2+0x2+1x2
Digits = 0 to (b-1) = 1x16+0x8+1x4+0x2+1x1
= 16+0+4+0+1 10100(2)=20(10)
= 0 to (2-1)
= 0 and 1 = 21(10) 00101(2)=5(10)

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 13


Converting from Binary Number System to Other
Number System.
Conversion Techniques
 Converting from binary number system to other number systems.
Binary Number System(2)
Binary to Octal,
Binary to Decimal,
Binary to Hexadecimal, Binary Number System (base 2)
Binary to other Bases
Octal Number System(8)
Octal to Binary,
Expansion method
Octal to Decimal,
Binary to Decimal Number System (base 10)
Octal Hexadecimal,
Octal to other Bases Group 3 bits
Binary to Octal Number System (base 8)
Decimal Number System(10)
Decimal to Binary, Group 4 bits
Decimal to Octal, Binary to Hexadecimal Number System (base 16)
Decimal to Hexadecimal,
Decimal to other Bases Depends
Hexadecimal Number System(16)
Binary to other Number Systems
Hexadecimal to Binary,
Hexadecimal to Octal,
Hexadecimal to Decimal,
Hexadecimal to other bases https://www.youtube.com/@BojkenShehuAcademy

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 14


Converting from Binary Number System to Decimal
Number System.
Expansion method
 Example 01: 10011(2) =X(10) Number in Decimal system
base x base 10
Base 2 – Digits [0,1] Division method

∑ face value x place value


 Converting from Binary (base-2) to Binary Number Position
LSB 1 Position = 0
Decimal (base-10).
1 Position = 1
0 Position = 2
1. Starting from LSB, multiply each
n 0 Position = 3
positional value with 2 when n is
MSB 1 Position = 4
position.
2. Add all the results. Homework:
10011(2) =19(10) 11011(2) = __(10)
1111(2) =__(10)
https://www.youtube.com/@BojkenShehuAcademy

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 15


Converting from Binary Number System to Octal
Number System.
 Example 02: 1001101(2) =X(8) Left side to MSB MSB LSB

 Converting from Binary (base-2) to 1001101(2)


Binary Octal
Octal (base-8). Number Number
base 2 001 001 101
000 0
1. Starting from LSB, group 3 bits. 001 1
base 8 1 1 5
2. If 1 or 2 Bits less in the 3 bit group, 010 2
add 0’s after MSB (left side to MSB) 1001101(2) =115(8) 011 3
to form 3 bit group.
100 4
3. Convert decimal equivalent for each
101 5
group of 3 bit. Homework:
11011(2) = __(8) 110 6
1111(2) =__(8) 111 7
https://www.youtube.com/@BojkenShehuAcademy

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 16


Converting from Binary Number System to Octal
Number System.
Left side to MSB MSB LSB Right side to LSB
 Example 03: 10011.01(2) =X(8)
010011.010(2)
 Converting from Binary (base-2) to Binary Octal
Octal (base-8). base 2 010 011 010 Number Number
000 0
1. Starting from LSB, group 3 bits. base 8 2 3 2 001 1
2. If 1 or 2 Bits less in the 3 bit group, 010 2
add 0’s after MSB (left side to MSB) 10011.01(2) =23.2(8) 011 3
to form 3 bit group.
100 4
3. Convert decimal equivalent for each
101 5
group of 3 bit. Homework:
110.11(2) = __(8) 110 6
11.1(2) =__(8) 111 7
https://www.youtube.com/@BojkenShehuAcademy

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 17


Converting from Binary Number System to Hexadecimal
Number System.
Binary Hexadecimal
Number Number
MSB LSB
 Example 04: 100110111(2) =X(16) Left side to MSB 0000 0

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

1. Starting from LSB, group 4 bits. base 16 1 3 7 0110 6

2. If 1,2 or 3 Bits less in the 4 bit 0111 7

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

3. Convert decimal equivalent for each 1011 B

group of 4 bit. Homework:


1100 C

1101 D
111001111(2) = __(16)
1110 E
1111(2) =__(16)
https://www.youtube.com/@BojkenShehuAcademy 1111 F

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 18


Converting from Octal Number System to Other Number
System.
Conversion Techniques  Converting from octal number system to other number systems.
Binary Number System(2)
Binary to Octal,
Binary to Decimal,
Binary to Hexadecimal, Octal Number System (base 8)
Binary to other Bases
Octal Number System(8)
Octal to Binary, Group 3 bits
Octal to Decimal,
Octal to Binary Number System (base 2)
Octal Hexadecimal,
Octal to other Bases Expansion method
Octal to Decimal Number System (base 10)
Decimal Number System(10)
Through base 2
Decimal to Binary, or base 10
Decimal to Octal, Octal to Hexadecimal Number System (base 16)
Decimal to Hexadecimal,
Decimal to other Bases Depends
Hexadecimal Number System(16)
Octal to other Number Systems
Hexadecimal to Binary, https://www.youtube.com/@BojkenShehuAcademy
Hexadecimal to Octal,
Hexadecimal to Decimal,
Hexadecimal to other bases

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 19


Converting from Octal Number System to Binary
Number System.
 Example 05: 121(8) = X(2)  Example 06: 72.6(8) = X(2) Binary Octal
Number Number
convert to convert to 000 0
Base 8 Base 2 Base 8 Base 2
001 1
010 2
base 8 1 2 1 base 8 7 2 6
011 3
100 4
base 2 001 010 001 base 2 111 010 110
101 5
110 6
121(8) =1010001(2) 72.6(8) =111010.110(2) 111 7

https://www.youtube.com/@BojkenShehuAcademy Homework: 325(8) = X(2)

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 20


Converting from Octal Number System to Decimal
Number System.
 Example 07: Expansion method
172(8) =X(10) Decimal
Number in
system
Base 8 – Digits [0,1,2,3,4,5,6,7] base x
base 10
Division method

 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)

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 21


Converting from Octal Number System to Hexadecimal
Number System, Case 1.
 Example 08: 121(8) =X(16)

Base 8 convert to Base 2 convert to Base 16


121(8) = 81(2) 81(2) = 51(16)
https://www.youtube.com/@BojkenShehuAcademy
base 8 1 2 1
 Case 1: Converting from Octal (base 8) to
Hexadecimal (base 16).
base 2 001 010 001

1. Convert Octal (base 8) to Binary (base 2).


base 16 0000 0101 0001
2. Convert Binary (base 2) to Hexadecimal (base 16).
0 5 1
Homework: 325(8) =X(16) 121(8) =51(16)
Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 22
Converting from Octal Number System to Hexadecimal
Number System, Case 2.
 Example 09: 121(8) =X(16) https://www.youtube.com/@BojkenShehuAcademy

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

Homework: 765(8) =X(16)


121(8) =51(16) 5/16 0 5

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 23


Converting from Decimal Number System to Other
Number System.
Conversion Techniques  Converting from decimal number system to other number systems.
Binary Number System(2)
Expansion method
Binary to Octal,
Binary to Decimal, Number in Decimal system
Binary to Hexadecimal, base x base 10
Binary to other Bases Division method
Octal Number System(8)
Octal to Binary, Decimal Number System (base 10)
Octal to Decimal,
Octal Hexadecimal,
Division method
Octal to other Bases Decimal to Binary Number System (base 2)
Decimal Number System(10)
Decimal to Binary, Division method
Decimal to Octal, Decimal to Octal Number System (base 8)
Decimal to Hexadecimal,
Decimal to other Bases Division method
Decimal to Hexadecimal Number System (base 16)
Hexadecimal Number System(16)
Hexadecimal to Binary, Division method
Hexadecimal to Octal, Decimal to other Number Systems
Hexadecimal to Decimal,
Hexadecimal to other bases https://www.youtube.com/@BojkenShehuAcademy
Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 24
Converting from Decimal Number System to Other
Number Systems Using Division Method.
 With help of expansion method (from base x to base 10) and division method (from
base 10 to base x), any problem on number systems can be solved.
Expansion method
Decimal
Number in
system
base x
base 10
Division method
 Division method:

1. Divide the integer part by base.


2. Continue the division till you get the number which is less than base.
3. Collect the digits from bottom to top. https://www.youtube.com/@BojkenShehuAcademy

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 25


Converting from Decimal Number System to other
Number Systems using Division Method. Decimal to
Binary Conversion.
Expansion method
 Example 10: 28(10) =X(2) X > 28 Decimal
Number in
system
base x
Base 2 – Digits [0,1] base 10
Division method

Number Division Reminder


28/2 14 0 https://www.youtube.com/@BojkenShehuAcademy
14/2 7 0
Homework:
7/2 3 1 204(10) = __(2)
3/2 1 (less than base) 1 28(10) =11100(2) 82(10) =__(8)
59(10) =__(16)

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 26


Converting from Decimal Number System to other
Number Systems using Division Method. Decimal to
Binary Conversion.
 Example 11: 51(10) =X(2) X > 51 Expansion method
Decimal
Number in
Base 2 – Digits [0,1] system
base x
base 10
Number Division Reminder Division method
51/2 25 1
25/2 12 1
https://www.youtube.com/@BojkenShehuAcademy
12/2 6 0
Homework:
6/2 3 0 204(10) = __(2)
3/2 1 (less than base) 1 51(10) =110011(2) 82(10) =__(8)
59(10) =__(16)

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 27


Converting from Decimal Number System to other
Number Systems using Division Method, Decimal to
Binary Conversion.
Expansion method
 Example 12: 13(10) =X(2) X>13 Decimal
Number in
system
base x
base 10
Base 2 – Digits [0,1] Division method
https://www.youtube.com/@BojkenShehuAcademy

Number Division Reminder


13/2 6 1 Homework:
6/2 3 0 67(10) =X(2)
13(10) = 1101(2) 34(10) =X(2)
3/2 1 (less than base) 1
18(10) =X(2)

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 28


Converting from Decimal Number System to other
Number Systems using Division Method, Decimal to
Binary Conversion.
 Example 13: 25.625(10) =X(2) Expansion method
Decimal
Number in
Base 2 – Digits [0,1] system
base x
base 10
Division method
 Division method:
1. Divide the integer part by base (b), and multiply the fractional part by base (b).

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

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 29


29
Converting from Decimal Number System to other
Number Systems using Division Method. Decimal to
Binary Conversion.
Expansion method
 Example 14: 25.625(10) =X(2) Number in
Decimal
system
base x
Base 2 – Digits [0,1] base 10
Division method
Table 1: Integer part. Table 2: Fractional part
Number Division Reminder Number Multiply Reminder
25/2 12 1 0.625x2 1.25 1
12/2 6 0 0.25x2 0.50 0
6/2 3 0 0.50x2 1.00 1
3/2 1 1
https://www.youtube.com/@BojkenShehuAcademy

25.625(10) =11001.101(2) Homework: 18.5(10) =X(2); 34.25(10) =X(2);129.75(10) =X(2)

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 30


Converting from Decimal Number System to Other
Number Systems Using Division Method. Decimal to
Octal Conversion.
Expansion method
 Example 15: 35(10) =X(8) Number in
Decimal
system
base x
Base 8 – Digits [0,1,2,3,4,5,6,7] base 10
Division method
 You are converting the number from larger base to the smaller base, so the value of x will be
grater than 35. 35(10) =43(8)
35<43
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. a(x) = b(y)
Number Division Reminder Number Division Reminder
x==y a=b
35/8 4 3 35/8 4 3
x>y a<b or b>a
4/8 0 4
https://www.youtube.com/@BojkenShehuAcademy x<y b<a or a>b

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 31


Converting from Decimal Number System to other
Number Systems using Division Method. Decimal to
Octal Conversion.
Expansion method
 Example 16: 25.625(10) =X(8) Number in
Decimal
system
Base 8 – Digits [0,1,2,3,4,5,6,7] base x
base 10
Division method
 Division method:
1. Divide the integer part by base (8), and multiply the fractional part by base (8).

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

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 32


Converting from Decimal Number System to other
Number Systems using Division Method. Decimal to
Octal Conversion.

 Example 17: Expansion method


25.625(10) =X(8) Decimal
Number in
system
Base 8 – Digits [0,1,2,3,4,5,6,7] base x
base 10
Division method
Table 1: Integer part. Table 2: Fractional part
Number Division Reminder Number Multiply Reminder
Homework:
25/8 3 1 0.625x8 5.000 5 2048(10) = X(8) ;
3/8 0 3 0.000x8 0.000 0 82.250(10) = X(8);

25.625(10) =31.5(8) https://www.youtube.com/@BojkenShehuAcademy

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 33


Converting from Decimal Number System to Other
Number Systems using Division Method. Decimal to
Hexadecimal Conversion.
Expansion method
 Example 18: 45(10) =X(16) Number in
Decimal
system
base x
base 10
Base 16 – Digits [0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F] Division method

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

45(10) =2D(16) https://www.youtube.com/@BojkenShehuAcademy

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 34


Converting from Decimal Number System to other
Number Systems using Division Method. Decimal to
Hexadecimal Conversion.
Expansion method
 Example 19: 254(10) =X(16) Decimal
Number in
system
base x
base 10
Division method
Base 16 – Digits [0,1,2,3,4,5,6,7,9,A,B,C,D,E,F]

Number Division Reminder


254/16 15 14 (E)
15/16 0 15 (F)

254(10) =FE(16)
https://www.youtube.com/@BojkenShehuAcademy

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 35


Converting from Decimal Number System to other
Number Systems using Division Method. Decimal to
Hexadecimal Conversion.
Expansion method
Decimal
 Example 20: 25.625(10) =X(16) Number in
system
base x
base 10
Base 16 – Digits[0,1,2,3,4,5,6,7,9,A,B,C,D,E,F] Division method

 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

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 36


Converting from Decimal Number System to Other
Number Systems using Division Method.
 With help of expansion method (from base x to base 10) and division method (from
base 10 to base x), any problem on number systems can be solved.

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

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 37


Converting from Decimal Number System to other
Number Systems using Division Method. Decimal to
Hexadecimal Conversion.
Expansion method
 Example 21: 25.625(10) =X(16) Number in
Decimal
system
base x
base 10
Base 16 – Digits [0,1,2,3,4,5,6,7,9,A,B,C,D,E,F] Division method

Table 1: Integer part. Table 2: Fractional part


Number Division Reminder Number Multiply Reminder
25/16 1 9 0.625x16 10.000 10(A)
1/16 0 1 0.000x16 0.000 0

Homework: 32.25(10) = X(16)


25.625(10) =19.A(16) https://www.youtube.com/@BojkenShehuAcademy

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 38


Converting from Decimal Number System to other
Number Systems using Division Method.

 Example 22: 50(10) =X(12) Expansion method


Decimal
Number in
system
Base 12 – Digits [0,1,2,3,4,5,6,7,8,9,A,B] base x
base 10
Division method
 You are converting the number from smaller base to the larger base, so the value of X will be
less than 50.
Table 1: Division method.
Number Division Reminder Homework:
50/12 4 2 1024(10) =X(12)
34(10) =X(8)
4/12 0 4
18(10) =X(2)
50(10) =42(12) X<50 https://www.youtube.com/@BojkenShehuAcademy

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 39


Converting from Decimal Number System to other
Number Systems using Division Method.
 Example 23: 27.4(10) =X(4) Expansion method
Decimal
Number in
system
Base 4 – Digits [0,1,2,3] base x
base 10
Division method
Table 1: Integer part. Table 2: Fractional part
Number Division Reminder Number Multiply Reminder
27/4 6 3 0.4x4 1.6 1
6/4 1 2 0.6x4 2.4 2
1/4 0 1 0.4x4 1.6 1
27.4(10) =123,1212(4) 0.6x4 2.4 2
------ ----- ----
Homework: 32.25(10) =X(4) https://www.youtube.com/@BojkenShehuAcademy

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 40


Converting from Decimal Number System to other
Number Systems using Division Method.
n
 Any number of the format (b )10 can represented by 1 followed by n-zeros in base b.
n
(b )10 =(1.000..n)b

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

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 42


Converting from Hexadecimal Number System to Binary
Number System.
Binary Hexadecimal
Number Number

 Example 27: 92F(16) =X(2) 0000 0

0001 1

0010 2
convert to
Base 16 Base 2 0011 3

0100 4

92F(16) =100100101111(2) 0101 5

0110 6

0111 7
base 16 9 2 F
1000 8

1001 9

base 2 1001 0010 1111 1010 A

1011 B

12F(16) =100100101111(2) 1100 C

1101 D

1110 E

https://www.youtube.com/@BojkenShehuAcademy Homework: A2E(16) = X(2) 1111 F

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 43


43
Converting from Hexadecimal Number System to Octal
Number System, Case 1.
 Example 28: 92F(16) =X(8) https://www.youtube.com/@BojkenShehuAcademy

Base 16 convert to Base 2 convert to Base 8


92F(16) = 100100101111(2) 100100101111(2)=4457(8)

 Case 1: Converting from Hexadecimal (base 16) to base 16 9 2 F


Octal (base 8).
base 2 1001 0010 1111
1. Convert Hexadecimal (base 16) to binary (base 2).
2. Convert Binary (base 2) to Octal (base 8). base 8 100 100 101 111

Homework: 325(16) =X(8) 92F(16) =4457(8) 4 4 5 7

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 44


44
Converting from Hexadecimal Number System to Octal
Number System, Case 2.
 Example 29: 92F(16) =X(8)

Base 16 convert to Base 10 convert to Base 8


92F(16) = 2351(10) 2351(10) = 4457(8)
2 1 0
 Case 2: Converting from Hexadecimal (base 16) 1) 92F(16) = 9x16+2x16+15x16
to Octal (base 8). = 9x256+2x16+15x1
= 2304+32+15 = 2351(10)
1. Convert Hexadecimal (base 16) to decimal 2)
(base 10). Number Division Reminder
2. Convert Decimal (base 10) to Octal (base 8). 2351/8 293 7
293/8 36 5

92F(16) = 4457(8) 36/8 4 4


https://www.youtube.com/@BojkenShehuAcademy

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 45


45
Converting from Hexadecimal Number System to
Decimal Number System.
Expansion method
 Example 30: 17F(16) =X(10)
Number in Decimal system
Base 16 – Digits [0,1,2,3,4,5,6,7,8,9,A,B.C.D,E,F] base x base 10

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

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 46


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

Hexadecimal Number System(16) Hexadecimal Number System(16)


Hexadecimal to Binary, Hexadecimal Addition,
Hexadecimal to Octal, Hexadecimal Subtraction,
Hexadecimal to Decimal, Hexadecimal Multiplication,
Hexadecimal to other bases https://www.youtube.com/@BojkenShehuAcademy Hexadecimal Division

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 47


Bojken Shehu, Dr
Polytechnic University of Tirana
Faculty of Information Technology

https://www.youtube.com/@BojkenShehuAcademy

bojken.shehu@gmail.com

Bojken Shehu, Dr | Computer Number Systems. Conversion Techniques | UPT | bojken.shehu@gmail.com 48

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy