Download as pdf or txt
Download as pdf or txt
You are on page 1of 64

SLIIT ACADEMY

FCIT– Semester 01

Information Technology

Lecture 05: Number Systems

Ruchira ManikkaArachchi

SLIIT Academy Pvt Ltd. © 2022


Intended Learning Outcomes
End of this lecture you will be able to learn ,
LO1:Understand the different number bases used with computers.
LO2: Apply the knowledge of number conversions to solve problems.

SLIIT Academy Pvt Ltd. © 2022


Number Systems
• Computers understand machine language. Every letter, symbol etc. that
we write in the instructions given to computer, it gets converted into
machine language.
• This machine language comprises of numbers. In order to understand the
language used by computers and other digital system it is crucial to have a
better understanding of number system.

SLIIT Academy Pvt Ltd. © 2022


Number Systems
• Number systems can be classified into its sub-types on the basis of base of
that system. Base of a number systems plays crucial role in understanding
the number system and to convert it from one sub-type to other sub-type.
• Base is also sometimes referred as radix; both these terms have same
meaning.

SLIIT Academy Pvt Ltd. © 2022


Number Bases
• We are used to dealing with numbers in the decimal system, where we use
a base of 10, counting up from 0 to 9 and then resetting our number to 0
and carrying 1 into another column.
• This is probably a result of having ten fingers.

SLIIT Academy Pvt Ltd. © 2022


Number Bases
• The alien shown here has only eight fingers, so it would most probably
work in base 8, counting from 0 up to 7 and then resetting to 0 and
carrying 1.
• So the number 10 in this system would mean 8 in the decimal system.

SLIIT Academy Pvt Ltd. © 2022


Computer Number Systems
o Decimal Numbers
o Binary Numbers
o Octal Numbers
Decimal, b=10 a={0,1,2,3,4,5,6,7,8,9}
o Hexadecimal Numbers
Binary, b=2 a={0,1}
Octal, b=8 a={0,1,2,3,4,5,6,7}
Hexadecimal, b=16 a={0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F}

SLIIT Academy Pvt Ltd. © 2022


Why is Binary used in Computers?
• The numeric values may be represented by two different voltages that
can be represented by binary;
• The original computers were designed to be high-speed calculators.
• The designers needed to use the electronic components available at the time.
• The designers realized they could use a simple coding system--the binary system to
represent their numbers.

SLIIT Academy Pvt Ltd. © 2022


Why is binary used in Computers?

• Computer's work using electronic circuits which can only be switched to


be on or off, with no shades of meaning in between.
• When a key is pressed the keyboard characters and numbers have to be
converted into a sequence of 1's and 0's so that the computer can open
or close its electronic switches in order to process the data.
• Because only two possible symbols can be used this is called a Binary
system. This system works to a base of 2.
SLIIT Academy Pvt Ltd. © 2022
Representing Information in Computers
All the different types of information in computers can be represented using
binary code.
• Numbers
• Letters of the alphabet and punctuation marks
• Microprocessor instruction
• Graphics/Video
• Sound
SLIIT Academy Pvt Ltd. © 2022
Decimal Number System
• The prefix “deci-” stands for 10
• The decimal number system is a Base 10 number system.
• There are 10 symbols that represent quantities: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
• Each place value in a decimal number is a power of 10.

SLIIT Academy Pvt Ltd. © 2022


Background Information

• Any number to the 0 (zero) power is 1.


0 0
4 = 1 , 16 = 1
0 ,482 = 1.
• Any number to the 1st power is the number itself.
101 = 10 , 491 = 49 , 8271 = 827

SLIIT Academy Pvt Ltd. © 2022


Decimal Number System
3 2 1 0
10 10 10 10

1000 100 10 1
Example : 1492 1 x 1000 = 1000
4 x 100 = 400
9 x 10 = 90
2x1 =+ 2
1492
SLIIT Academy Pvt Ltd. © 2022
Binary Numbers
• The prefix “bi-” stands for 2
• The binary number system is a Base 2 number system:
• There are 2 symbols that represent quantities: 0, 1
• Each place value in a binary number is a power of 2.

SLIIT Academy Pvt Ltd. © 2022


Conversion Among Number Bases

Decimal

Binary Octal

Hexa-
Decimal
SLIIT Academy Pvt Ltd. © 2022
Converting Decimal Numbers to Binary Numbers
• There are two methods that can be used to convert decimal numbers to
binary:
• Repeated Division Method
• Repeated Subtraction Method
• Both methods produce the same result, and you should use whichever
one you are most comfortable with.

SLIIT Academy Pvt Ltd. © 2022


The Repeated Division Method

Conversion Steps:
• Divide the number successively by 2.
• After each division get the integer quotient for the next iteration and
record the remainder ➔ which is either 1 or 0
• Repeat the steps until the quotient is equal to 0.
• The result is read from the last remainder upwards.

SLIIT Academy Pvt Ltd. © 2022


Practice Question 01
Convert the given Decimal numbers to Binary.
a) 2510
b) 7410
c) 12510

SLIIT Academy Pvt Ltd. © 2022


Practice Question 01 : Answer
Convert Decimal to Binary : 𝟐𝟓𝟏𝟎
2 25 2510 = 110012
2 12 1 r=1
2 6 0 r=0
The result is read from the last
2 3 0 r=0 remainder upwards
2 1 1 r=1
0 1 r=1
The process need to be stopped when quotient is equal to 0

SLIIT Academy Pvt Ltd. © 2022


The Repeated Subtraction Method
Ex: 85310 to Binary
Step 1:
Starting with the 1s place, write down all of the binary place values in order until you get to the
first binary place value that is GREATER THAN the decimal number you are trying to convert.
1024 512 256 128 64 32 16 8 4 2 1

SLIIT Academy Pvt Ltd. © 2022


The Repeated Subtraction Method Contd…
Step 2: Mark out the largest place value (it just tells us how many place values we need).
1024 512 256 128 64 32 16 8 4 2

0
853
Step 3: Subtract the largest place value from the decimal number. Place a
“1” under that place value.
853 – 512 = 341 Need to Place the 341
1024 512 256 128 64 32 16 8 4 2
0 1
341 SLIIT Academy Pvt Ltd. © 2022
The Repeated Subtraction Method
Step 4: 341 – 256 = 85 Need to Place the 85

1024 512 256 128 64 32 16 8 4 2


0 1 1 0
85
Step 5: 85 – 64 = 21 Need to Place the 21

1024 512 256 128 64 32 16 8 4 2


0 1 1 0 1 0
21

SLIIT Academy Pvt Ltd. © 2022


The Repeated Subtraction Method
Step 6: 21 – 16 = 5 Need to Place the 5

1024 512 256 128 64 32 16 8 4 2


0 1 1 0 1 0 1 0
5
Step 7: 5 – 4 = 1 Need to Place the 1

1024 512 256 128 64 32 16 8 4 2 1


0 1 1 0 1 0 1 0 1 0
1
Final Answer :01101010101
SLIIT Academy Pvt Ltd. © 2022
The Repeated Subtraction Method

Step 4:
For the rest of the place values, try to subtract each one from the previous result.
• If you can, place a “1” under that place value.
• If you can’ t, place a “0” under that place value.
Step 5:
Repeat Step 4 until all of the place values have been processed. The resulting set of 1s and 0s is
the binary equivalent of the decimal number you started with.
SLIIT Academy Pvt Ltd. © 2022
The Repeated Subtraction Method

SLIIT Academy Pvt Ltd. © 2022


Converting Decimal Numbers to Octal

Conversion Steps:
• Divide the number successively by 8.
• After each division get the integer quotient for the next iteration and
record the remainder which is a number in the range 0 to 7.
• Repeat the steps until the quotient is equal to 0.
• The result is read from the last remainder upwards.

SLIIT Academy Pvt Ltd. © 2022


Practice Question 02
Convert the given Decimal numbers to Octal.
a) 8510
b) 15810
c) 22510

SLIIT Academy Pvt Ltd. © 2022


Practice Question 02 : Answer
Convert Decimal to Octal : 𝟖𝟓𝟏𝟎
8 85
8 10 5 r=5 8510 = 1258
8 1 2 r=2
The result is read from the last
0 1 r=1 remainder upwards

The process need to be stopped when quotient is equal to 0

SLIIT Academy Pvt Ltd. © 2022


Converting Decimal Numbers to Hexa-Decimal

Conversion Steps:
• Divide the number successively by 16.
• After each division get the integer quotient for the next iteration and
record the remainder which is a number in the range 0 to 9 and
A,B,C,D,E and F
• Repeat the steps until the quotient is equal to 0.
• The result is read from the last remainder upwards.
SLIIT Academy Pvt Ltd. © 2022
Practice Question 03
Convert the given Decimal numbers to Hexa-Decimal.
a) 12510
b) 35810
c) 45610

SLIIT Academy Pvt Ltd. © 2022


Practice Question 03 : Answer
Convert Decimal to Hexadecimal: 𝟏𝟐𝟓𝟏𝟎
16 125
12510 = 7D16
16 7 13 r =13 =D
0 7 r=7 The result is read from the last
remainder upwards
The process need to be stopped when quotient is equal to 0

SLIIT Academy Pvt Ltd. © 2022


Converting Binary Numbers to Decimal
Conversion Steps:
• Take the Binary number.
• Consider the left most none zero bit, double it and add it to the bit on its
right.
• Now take this result, double it and add it to the next bit on the right.
• Continue in this way until the least significant bit has been added in.

SLIIT Academy Pvt Ltd. © 2022


Practice Question 04
Convert the given Binary numbers to Decimal.
a) 10112
b) 110102
c) 10110112

SLIIT Academy Pvt Ltd. © 2022


Practice Question 04 : Answer
Convert Binary to Decimal : 𝟏𝟎𝟏𝟏𝟐
1 0 1 1
+
2 10112 = 1110
*2
2 +
+
*2 4
5
10
*2
11

SLIIT Academy Pvt Ltd. © 2022


Converting Binary Numbers to Octal

Conversion Steps:
• Take binary number
• Divide the binary digits into groups of three ,starting from right side.
• Convert each group of three binary digits to one octal digit.

SLIIT Academy Pvt Ltd. © 2022


Practice Question 05
Convert the given Binary numbers to Octal.
a) 1100111002
b) 1011011002
c) 111010102

SLIIT Academy Pvt Ltd. © 2022


Practice Question 05 : Answer

Convert Binary to Octal : 𝟏𝟏𝟎𝟎𝟏𝟏𝟏𝟎𝟎𝟐 A B C


0 0 0 0
1 0 0 1
1 1 0 01 1 1 0 0 1100111002 = 6348 2 0 1 0
3 0 1 1
6 3 4 4 1 0 0
5 1 0 1
6 1 1 0
7 1 1 1

SLIIT Academy Pvt Ltd. © 2022


Converting Binary Numbers to Hexadecimal
Conversion Steps:
• Take the Binary number.
• From the bits into groups of four bits starting at the decimal point and
move leftwards.
• Replace each group of four bits with the corresponding hexadecimal
digit from 0 to 9, A, B, C, D, E, and F.

SLIIT Academy Pvt Ltd. © 2022


Practice Question 06
Convert the given Binary numbers to Hexa-Decimal.
a) 110011102
b) 1111102
c) 110010102

SLIIT Academy Pvt Ltd. © 2022


A B C D
Practice Question 06 : Answer 0
1
0
0
0
0
0
0
0
1
2 0 0 1 0
3 0 0 1 1
Convert Binary to Hexadecimal : 𝟏𝟏𝟎𝟎𝟏𝟏𝟏𝟎𝟐 4 0 1 0 0
5 0 1 0 1
1 1 0 0 11 1 0 110011102 = CE16
6 0 1 1 0
7 0 1 1 1
8 1 0 0 0
C E 9 1 0 0 1
A 1 0 1 0
B 1 0 1 1
C 1 1 0 0
D 1 1 0 1
E 1 1 1 0
F 1 1 1 1

SLIIT Academy Pvt Ltd. © 2022


Converting Octal Numbers to Decimal
Conversion Steps:
• Take the Octal number.
• Consider the left-most digit, multiply it by eight and add it to the digit on
its right.
• Then, multiply this subtotal by eight and add it to the next digit on its right.
• The process ends when the left-most digit has been added to the subtotal.

SLIIT Academy Pvt Ltd. © 2022


Practice Question 07
Convert the given Octal numbers to Decimal.
a) 178
b) 1158
c) 1248
d) 2528

SLIIT Academy Pvt Ltd. © 2022


Practice Question 07 : Answer
Convert Octal to Decimal : 𝟏𝟕𝟖
1 7 178 =
+ 1510
8
*8
15
Convert Octal to Decimal : 𝟏𝟏𝟓𝟖
1 1 5
+
8 1158 = 7710
*8
9 +

*8 72
77
SLIIT Academy Pvt Ltd. © 2022
Converting Octal Numbers to Binary
Conversion Steps:
• Take the Octal number.
• Each octal digit is simply replaced by its 3-bit binary equivalent.
• It is important to remember that (say) 3 must be replaced by 011 and not
11.

SLIIT Academy Pvt Ltd. © 2022


Practice Question 08
Convert the given Octal numbers to Binary.
a) 178
b) 2348
c) 2558
d) 3678

SLIIT Academy Pvt Ltd. © 2022


Practice Question 08 : Answer

Convert Octal to Binary : 𝟏𝟕𝟖 A B C


0 0 0 0
1 7 1 0 0 1
178 = 0011112 2 0 1 0
001 111 3 0 1 1
4 1 0 0
Convert Octal to Binary : 𝟐𝟑𝟒𝟖 5 1 0 1
6 1 1 0
2 3 4 7 1 1 1
2348 = 0100111002
010 011 100

SLIIT Academy Pvt Ltd. © 2022


Converting Hexadecimal Numbers to Decimal
Conversion Steps:
• Take the hexa-decimal number.
• Consider the left-most digit, multiply it by 16 and add it to the digit on its
right.
• Then, multiply this subtotal by 16 and add it to the next digit on its right.
• The process ends when the left-most digit has been added to the
subtotal.
SLIIT Academy Pvt Ltd. © 2022
Practice Question 09:
Convert the given Hexa-Decimal numbers to Decimal.
a) AB16
b) 11516
c) 3C16
d) B216

SLIIT Academy Pvt Ltd. © 2022


Practice Question 09 : Answer
Convert Hexa-Decimal to Decimal : 𝑨𝑩𝟏𝟔
A B AB =
+ 16 17110
160
* 16
171
Convert Hexa-Decimal to Decimal : 𝟏𝟏𝟓𝟏𝟔
1 1 5
+
16 11516 = 27710
* 16 +
17

* 16 272
277 SLIIT Academy Pvt Ltd. © 2022
Converting Hexadecimal Numbers to Binary
Conversion Steps:
• Take the Hexa-Decimal number.
• Each hexadecimal digit is replaced by its 4-bit binary equivalent.

SLIIT Academy Pvt Ltd. © 2022


Practice Question 10
Convert the given Hexa-Decimal numbers to Binary.
a) AC16
b) 21316
c) 3B16
d) E216

SLIIT Academy Pvt Ltd. © 2022


A B C D
Practice Question 10 : Answer 0
1
0
0
0
0
0
0
0
1
2 0 0 1 0
3 0 0 1 1
Convert Hexadecimal to Binary : 𝐀𝐂𝟏𝟔 4 0 1 0 0
5 0 1 0 1
A C 6 0 1 1 0
𝐴𝐶16 =101011002 7 0 1 1 1
1010 1100 8 1 0 0 0
9 1 0 0 1
A 1 0 1 0
Convert Hexadecimal to Binary : 𝟐𝟏𝟓𝟏𝟔 B 1 0 1 1
C 1 1 0 0
2 1 5 D 1 1 0 1
2158 = 0010000101012 E 1 1 1 0
0010 0001 0101 F 1 1 1 1

SLIIT Academy Pvt Ltd. © 2022


Conversion of Fractions:
Converting Decimal Fractions to Binary Fractions
Conversion Steps:
• Multiply the fractional decimal number by 2.
• Integral part of resultant decimal number will be first digit of fraction
binary number.
• If the integer part of the fraction is still less than 1, assign it a 0. If it’s > 1,
then assign it a 1, then keep multiplying by 2 and following this scheme.
• Stop the process when fractional part is equal to 0.
SLIIT Academy Pvt Ltd. © 2022
Practice Question 11
Convert the given Decimal Fractions to Binary Fractions.
a) 0.125 10
b) 0.375 10
c) 0.625 10

SLIIT Academy Pvt Ltd. © 2022


Practice Question 11 : Answer
Convert Decimal Fraction to Binary Fraction: 𝟎. 𝟏𝟐𝟓𝟏𝟎

0.125 * 2 = 0.250 0
0.250 * 2 = 0.500 0 0.12510 = 0.0012
0.500 * 2 = 1.000 1
0.000 * 2 = 0.000 Process Ends

SLIIT Academy Pvt Ltd. © 2022


Practice Question 12
Convert the given Decimal Fractions to Binary Fractions.
a) 22.5 10
b) 54.875 10

SLIIT Academy Pvt Ltd. © 2022


Practice Question 12 : Answer
Convert Decimal to Binary : 𝟐𝟐𝟏𝟎 Convert Decimal Fraction to Binary Fraction: 𝟎. 𝟓𝟏𝟎
2 22 0.500 * 2 = 1.000 1
2 11 0 r=0 Process Ends
0.000 * 2 = 0.000
2 5 1 r=1
2 2 1 r=1 0.510 = 0.12
2 1 0 r=0
0 1 r=1
2210 = 101102 𝐅𝐢𝐧𝐚𝐥𝐀𝐧𝐬𝐰𝐞𝐫 ∶

22.510 = 10110.12
SLIIT Academy Pvt Ltd. © 2022
Conversion of Fractions:
Converting Binary Fractions to Decimal Fractions
Conversion Steps:
• Take the fractional binary number.
• Consider the right most none zero bit, divide by 2 (multiply by ½ ) and
add it to the bit on its left.
• Now take this result, divide by 2 (multiply by ½ ) and add it to the next bit
on the left.
• Continue in this way until the least significant bit has been added in.
SLIIT Academy Pvt Ltd. © 2022
Practice Question 13
Convert the given Binary Fractions to Decimal Fractions.
a) 0.101 2
b) 0.1101 2

SLIIT Academy Pvt Ltd. © 2022


Practice Question 13 : Answer
Convert Binary Fraction to Decimal Fraction: 𝟎. 𝟏𝟎𝟏𝟐
0. 1 0 1
+1 5
*1/2 0.1012 = = 0.62510
2 8
+ 𝟏
𝟐
1
4 *1/2
𝟓
𝟒
𝟓
𝟖 *1/2 SLIIT Academy Pvt Ltd. © 2022
Practice Question 14
Convert the given Binary Fractions to Decimal Fractions.
a) 10111.111 2
b) 1100.11 2

SLIIT Academy Pvt Ltd. © 2022


Practice Question 14 : Answer
Convert Binary to Decimal : 𝟏𝟎𝟏𝟏𝟏𝟐 Convert Binary Fraction to Decimal Fraction: 𝟎. 𝟏𝟏𝟏𝟐
1 0 1 1 1 0. 1 1 1
+
2 + 1
*2 *1/2
2 + 2
+ + 𝟑 7
4 0.1112 = = 0.87510
*2 + 𝟐 8
5 3
10 4 *1/2
*2
𝟕
11
𝟒 𝐅𝐢𝐧𝐚𝐥𝐀𝐧𝐬𝐰𝐞𝐫 ∶
22
*2 𝟕 10111.1112 = 23.87510
101112 = 2310 23 𝟖 Pvt *1/2
SLIIT Academy Ltd. © 2022
Practice Question 15
Copy and complete the table below. All your workings need to be displayed
in your answer paper.
Decimal Binary Octal Hexadecimal
6010 ------------------- ------------------- --------------------

--------------------- ------------------ 5108 --------------------

--------------------- ------------------ ------------------ 𝐴𝐹16

--------------------- 101101102 ------------------ --------------------

SLIIT Academy Pvt Ltd. © 2022


• Number bases used with computers
• Why binary?
• Number Base Conversion
• Conversion of Fractional numbers.

SLIIT Academy Pvt Ltd. © 2022

You might also like