Uni† 1 Fundamen†al of Compu†ers
Number System
We are familiar with the decimal number system which is used in
our day-to-day work. Ten digits are used to four decimal
numbers. To represent these decimal digits, ten separate symbols
0, 1, 2, 3, 4, 5, 6, 7, 8 and 9 are used. But a digital computer
stores, understands and manipulates information composed of any
zeros and ones. So, each decimal digit, letters, symbols etc.
written by the programmer (a user) are converted to binary codes
in the form of 0’s and 1’s within the computer. The no. system
is divided into some categories according to the base (or radix) of
the system as binary octal and hexadecimal. If a number system
of base r is a system, then the system has r distinct symbols for r
digits. The knowledge of the number system is essential to
understand the operation of a computer.
Decimal Number System
Decimal no. system have ten digits represented by
0,1,2,3,4,5,6,7,8 and 9. So, the base or radix of such system
is 10.
Uni† 1 Fundamen†al of Compu†ers
In this system the successive position to the left of the decimal
point represent units, tens, hundreds, thousands etc. For example,
if we consider a decimal number 257, then the digit representations
are
2 5 7
Hundred Tens Units
Position Position
The weight of each digit of a number depends on its relative
position within the number.
Example 1.1:
The weight of each digit of the
decimal no. 6472 =
6000+400+70+2
= 6X103+4X102+7X101+2X100
The weight of digits from right
hand side are- Weight
of 1st digit =2X
100 Weight of 2nd
digit =7X
Uni† 1 Fundamen†al of Compu†ers
101 Weight of 3rd digit
= 4 X 102 Weight of
4th digit =6X
103
The above expressions can be written in general forms as the
weight of nth digit of the number from the right hand side
= nth digit X 10n-1
= nth digit X (base) n-1
The no. system in which the weight of each digit depends on
its relative position within the number is called positional
number system. The above form of general expression is
true only for positional number system.
Uni† 1 Fundamen†al of Compu†ers
Binary Number System
Only two digits 0 and 1 are used to represent a binary
number system. So the base or radix of binary system is two
(2). The digits 0 and 1 are called bits (Binary Digits). In this
number system the value of the digit will be two times
greater than its predecessor. Thus the value of the places
are-
<-- <-- 32 <-- 16 <--8 <--4 <--2 <--1
The weight of each binary bit depends on its relative
position within the number. It is explained by the following
example--
Example:
The weight of bits of the binary number 10110 is-
= 1X24+0X23+1X22+1X21+0X20
= 16+0+4+2+0 = 22(decimal number)
The weight of each bit of a binary no. depends on its relative
pointer within the no. And explained from right hand side
Weight of 1st bit = 1st
bit X 20 Weight of 2nd
Uni† 1 Fundamen†al of Compu†ers
bit = 2nd bit X 21
................................................
...............................................
And so on.
The weight of the nth bit of the number from right hand
side
=nth bit X 2n-1
=nth bit X (Base) n-1
It is seen that this rule for a binary number is same as that
for a decimal number system. The above rule holds good for
any other positioned number system. The weight of a digit
in any positioned number system depends on its relative
position within the number and the base of the number
system.
Uni† 1 Fundamen†al of Compu†ers
Table 1.1 shows the binary equivalent numbers for
decimal digits.
Table: Binary equivalent of decimal numbers
Decimal Equivalent Binary
Number Number
0 0
1 1
2 10
3 11
4 100
5 101
6 110
7 111
8 1000
9 1001
Octal Number System
A commonly used positional number system is the Octal
Number System. This system has eight (8) digit
representations as 0,1,2,3,4,5,6 and 7. The base or radix of
this system is 8. The values increase from left to right as 1,
8, 64, 512, 4096 etc. The
Decimal value 8 is represented in octal as 10, 9 as 11, and 10
as 12 and so on. As 8=23, an octal number is represented
by a group of three binary bits. For example 3 is represented
Uni† 1 Fundamen†al of Compu†ers
as 011, 4 as 100 etc.
Table: The octal number and their binary
representations.
Decimal Octal Number Binary Coded
Number Octal No.
0 0 000
1 1 001
2 2 010
3 3 011
Uni† 1 Fundamen†al of Compu†ers
4 4 100
5 5 101
6 6 110
7 7 111
8 10 100 000
10 12 001 010
15 17 001 111
16 20 010 000
Hexadecimal Number System
The hexadecimal number system is now extensively used
in computer industry. Its base (or radix) is 16, i.e.
0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F. The hexadecimal
numbers are used to represent binary numbers because of
case of conversion and compactness. As 16=24 ,
hexadecimal number is represented by a group of four
binary bits. For example, 5 is represented by 0101. Table
2.3 shows the binary equivalent of a decimal number and
its hexadecimal representation.
Table: Hexadecimal number and their Binary
representation
Deci No. Hexadecimal Binary coded
mal No. Hex. No
0 0 0000
Uni† 1 Fundamen†al of Compu†ers
1 1 0001
2 2 0010
3 3 0011
4 4 0100
5 5 0101
6 6 0110
7 7 0111
8 8 1000
Uni† 1 Fundamen†al of Compu†ers
9 9 1001
1 A 1010
0
1 B 1011
1
1 C 1100
2
1 D 1101
3
1 E 1110
4
1 F 1111
5
1.4 Number System
Conversion
As the computer uses different number systems, there is a
process of converting generally used decimal number systems to
other number systems and vice-versa.
Binary to Decimal Conversion
To convert a binary number to its decimal equivalent we use
the following expression. The weight of the nth bit of the
number from right hand side
=nth bit X 2n-1
First we mark the bit position and then we give the weight of
Uni† 1 Fundamen†al of Compu†ers
each bit of the number depending on its position. The sum of
the weight of all bits gives the equivalent number.
Example: Convert binary (110100)2 to its decimal equivalent
Solution:
(110100)2=1X25+1X24+0X23+1X22+0X21+0X20
=32+16+0+4+0+0
= (52)10
(110100)2= (52)10
Uni† 1 Fundamen†al of Compu†ers
Example: Converting binary fraction (111011.101)2 to its
equivalent decimal fraction.
Solution:
(111011.101)2 =
(1X25+1X24+1X23+0X22+1X21+1X20)+(1X 2-1+0X2-
2+1X2-3)
= (32+16+8+0+2+1) + (0.5+0+0.125)
= (59.625)10
(111011.101)2 = (59.625)10
Decimal to Binary Conversion
There are different methods used to convert decimal number
to binary number. The most common method is repeated-
division method. In this method, the number is successively
divided by 2 and its remainders 0’s abd 1’s are recorded.
The final binary result is obtained by assembling the
remainders in reverse order to obtain the binary equivalent
of the decimal number. In this case, the last remainder will
be the most significant bit (MSB).
Example 1.5 Convert (75)10 to its binary equivalent
2 |75 Remainder
2|37 1
Uni† 1 Fundamen†al of Compu†ers
2|18 1
2|9 0 Read in
2|4 1 reverse order
2|2 0
1 0
So, (75)10= (1001011)2
The methods to convert the fraction decimal number to its
binary equivalent is repeatedly multiply the fraction part by
2 and count the most significant bits in the order they
appear.
Uni† 1 Fundamen†al of Compu†ers
Example: Convert decimal fraction (12.75)10 to its
equivalent binary fraction.
2|12 Remain MSB .75
der
2|6 0 X2
2|3 0 1.5 Read
0
1 1 X2 the
MSB
1.00bits.
So, (12)10 = (1100)2 and (.75)10 = (.11)2
Now, (12.75)10 = (1100.11)2
Octal to Decimal Conversion
The method of converting octal numbers to decimal
numbers is simple. The decimal equivalent of an octal
number is the sum of the numbers multiplied by their
corresponding weights.
Example: Find decimal equivalent of octal number (153)8
Solution: 1X82 + 1X81 + 1X80 = 64
+ 40 + 3 = 107 So, (153)8
= (107)10
In†roduc†ion †o Informa†ics 10 U††arakhand Open Universi†y
Uni† 1 Fundamen†al of Compu†ers
Example: Find decimal equivalent of octal number (123.21)8
Solution: (1X82 + 2X81 + 3X80) + (2X8-1 + 1X8-2)
= (64 +16 + 3) + (0.25 + 0.0156) = 83.2656
So, (123.21)8 = (83.2656)10
Decimal to Octal Conversion
The procedure for conversion of decimal numbers to octal
numbers is exactly similar to the conversion of decimal
number to binary numbers except replacing 2 by 8.
In†roduc†ion †o Informa†ics 11 U††arakhand Open Universi†y
Uni† 1 Fundamen†al of Compu†ers
Example: Find the octal equivalent of decimal (3229)10
Solution:
Remain
ders 8 | 3229
8 | 403 5 read
in
8 | 50 3 rever
se
8|6 2 order
0 6
So, (3229)10= (6235)8
Example: Find the octal equivalent of (.123)10
Solution: Octal equivalent of fractional part of a decimal
number as follows:
8 X 0.123 = 0
0.984
8 X 0.984 = 7 read in
7.872
8 X 0.872 = 6 forward
6.976 order
8 X 0.976 = 7
7.808
Read the integer to the left of the decimal point
The calculation can be terminated after a few steps if the
In†roduc†ion †o Informa†ics 12 U††arakhand Open Universi†y
Uni† 1 Fundamen†al of Compu†ers
fractional part does not become zero.
The octal equivalent of
(0.123)10= (0.0767)8
Hexadecimal to Decimal Conversion
The method of converting hexadecimal numbers to decimal
number is simple. The decimal equivalent of a hexadecimal
number is the sum of the numbers multiplied by their
corresponding weights.
In†roduc†ion †o Informa†ics 13 U††arakhand Open Universi†y
Uni† 1 Fundamen†al of Compu†ers
Example: Find the decimal equivalent of (4A83)16
Solution:
(4A83)16= (4 X 163) + (10 X 162) + (8 X 191) +
(3 X 160)
=16384+2560+128+3
= (19075)10
(4A83)16= (19075)10
Example: Find the decimal equivalent of (53A.0B4)16
Solution:
(53A.0B4)16= (5 X 162) + (3 X 161) + (10 X 160) + (0 X 16-
1) + (11 X 16-2) + (4 X
16-3)
=1280+48+10+0+0.04927+0.0009765
= (1338.0439)10
(53A.0B4)16=(1338.0439)
10
In†roduc†ion †o Informa†ics 14 U††arakhand Open Universi†y
Uni† 1 Fundamen†al of Compu†ers
Decimal to Hexadecimal Conversion
To convert a decimal integer number to hexadecimal,
successively divide the given decimal number by 16 till the
quotient is zero. The last remainder is the MSB (Most
Significant Bit). The remainders read from bottom to top
give the equivalent hexadecimal integer.
To convert a decimal fraction to hexadecimal, successively
multiply the given decimal fraction by 16, till the product is
zero or till the required accuracy is obtained, and collect all
the integers to the left of decimal point. The first integer is
the MSB and the integers read from top to bottom give the
hexadecimal fraction.
In†roduc†ion †o Informa†ics 15 U††arakhand Open Universi†y
Uni† 1 Fundamen†al of Compu†ers
Example: Convert decimal (1234.675)10 to hexadecimal.
Solution:
1st consider (1234)10
Remainder
Decim Hexadec
al imal
16|1234 2 2
read
in
16|77 13 D rever
se
order
16|4 4 4
(1234)10 = (4D2)16
Conversion of (0.675)10
Hexadecimal conversion of fractional part of a decimal number as
follows:
Deci Hexadeci
mal mal
0.675 X 16 = 10.8 10 A
0.800 X 16 = 12.8 12 C
0.800 X 16 = 12.8 12 C
0.800 X 16 = 12.8 12 C
(0.675)10= (0.ACCC)16
Hence, (1234.675)10=
(4D2.ACCC)16
If the decimal number is very large, it is tedious to convert the
In†roduc†ion †o Informa†ics 16 U††arakhand Open Universi†y
Uni† 1 Fundamen†al of Compu†ers
number to binary directly. So it is always advisable to convert
the number into hex first, and then convert the hex to binary.
In†roduc†ion †o Informa†ics 17 U††arakhand Open Universi†y