Module 01 - Chapter 1
Module 01 - Chapter 1
(1×162)+(10×161)+(15×160)
256+160+15=431
∴(1AF)16=(431)10
BINARY TO DECIMAL CONVERSION
• Binary to decimal conversion is done to convert binary number
system to decimal number system, which means base 2 numeral
system are converted into base 10 numeral system.
• It is important to know binary to decimal conversion because of
computer programming applications. so the machine can understand
only binary number system in form of 0 and 1 whereas humans can
easily understand decimal number system that includes all 10 digits.
• So, it is important to understand how to convert binary number
systems into decimal number systems.
• There are two main methods for converting binary number systems
into decimal number systems. these methods are:
1.Positional notation
2.Doubling
CONVERSION USING POSITIONAL NOTATION
• Write the binary number and count the power of 2 from right to left, starting from 0
onwards.
• Now each binary number has the corresponding power of 2 starting from right to
left. so the most significant bit will have the highest power of 2.
• Add the product of the second step
• The final answer will be converted into a decimal number that is base 10.
Binary Number: (101)2
101
1 x 22 + 0 x 21 + 1 x 20
4+0+1
• (10011) (10000101)
CONVERSION FROM DECIMAL TO BINARY NUMBER
SYSTEM
• There are various direct or indirect methods to convert a decimal number into
binary number.
• In an indirect method, you need to convert a decimal number into other number
system (e.g., octal or hexadecimal), then you can convert into binary number by
converting each digit into binary number.
• Convert decimal number 125 into binary number.
First convert it into octal or hexadecimal number,
= (125)10
= (1x82+7x81+5x80)10 or
(7x161+13x160)10
Because base of octal and hexadecimal are 8 and 16
respectively.
= (175)8 or (7D)16
Then convert it into binary number by converting each digit.
= (001 111 101)2 or
(0111 1101) = (01111101)
• Here are two direct methods are available for converting a decimal
number into binary number:
i. Performing short division by two with remainder (for integer part)
ii. Performing short multiplication by two with result (for fractional
part)
112 / 2 = 56 0
56 / 2 = 28 0
28 / 2 = 14 0
14 / 2 = 7 0
7/2=3 1
3/2=1 1
1/2=0 1
ii. performing short multiplication by two with result (for fractional part)
0.81252 x 2= 1.625 1
0.6252 x 2= 1.25 1
0.252 x 2= 0.50 0
0.52 x 2= 1.0 1
0x2=0 0
CONVERSION FROM BINARY TO HEXADECIMAL NUMBER
SYSTEM
• POSITIONAL NUMBER SYSTEM
• USING GROUPING
• That means weight of the positions from right to left are as 160, 161,
162, 163and so on. for the integer part
• Weight of the positions from left to right are as 16-1, 16-2, 16-3and so
on. for the fractional part.
• Convert binary number 1101010 into hexadecimal number.
First convert this into decimal number:
= (1101010)2
= 1x26+1x25+0x24+1x23+0x22+1x21+0x20
= 64+32+0+8+0+2+0
= (106)10
= (001100101.110111)2
= (0 0110 0101 . 1101 1100)2
= (0110 0101 . 1101 1100)2
= (6 5 . D C)16
= (65.DC)16
CONVERSION FROM HEXADECIMAL TO DECIMAL NUMBER
SYSTEM
• There are various indirect or direct methods to convert a hexadecimal number into
decimal number.
• In an indirect method, you need to convert a hexadecimal number into binary or octal
number, then you can convert it into decimal number.
• Convert hexadecimal number f1 into decimal number.
First convert it into binary or octal number,
= (F1)16
= (1111 0001)2 or (011 110 001)2
Because in binary, value of F and 1 are 1111 and 0001 respectively.
Then convert it into decimal number multiplying power of its position of base.
= (1x27+1x26+1x25+1x24+0x23+0x22+0x21+1x20)10 or
(3 6 1)8
= (1x27+1x26+1x25+1x24+0x23+0x22+0x21+1x20)10 or
(3x82+6x81+1x80)10
= (241)10
You can directly convert a hexadecimal number into decimal number
using reverse method of decimal to hexadecimal number.
= (10485760+720896+49152+3328+224+15)10
= (11259375)10 which is answer.
0 0000 0011
1 0001 0100
2 0010 0101
3 0011 0110
4 0100 0111
5 0101 1000
6 0110 1001
7 0111 1010
8 1000 1011
9 1001 1100
Convert decimal number 23 to excess-3 code.
• So, according to excess-3 code we need to add 3 to both digit in the
decimal number then convert into 4-bit binary number for result of
each digit. therefore,
• = 23+33=56 =0101 0110 which is required excess-3 code for given
decimal number 23.
Convert decimal number 15.46 into excess-3 code.
• According to excess-3 code we need to add 3 to both digit in the
decimal number then convert into 4-bit binary number for result of
each digit. therefore,
• = 15.46+33.33=48.79 =0100 1000.0111 1001 which is required
excess-3 code for given decimal number 15.46.
GRAY CODE
• The reflected binary code or gray code is an ordering of the
binary numeral system such that two successive values differ in only one
bit (binary digit).
• Gray codes are very useful in the normal sequence of binary numbers
generated by the hardware that may cause an error or ambiguity during the
transition from one number to the next.
• So, the gray code can eliminate this problem easily since only one bit
changes its value during any transition between two numbers.
• Gray code is not weighted that means it does not depends on positional
value of digit.
• This cyclic variable code that means every transition from one value to the
next value involves only one bit change.
• Gray code also known as reflected binary code, because the first (n/2) values
compare with those of the last (n/2) values, but in reverse order.
CONSTRUCTING AN N-BIT GRAY CODE
• n-bit gray code can be generated recursively using reflect and
prefix method which is explained as following below.
0 0 00 00 000 000
1 1 01 01 001 001
10 11 010 011
11 10 011 010
100 110
101 111
110 101
111
100
Conversion Of Binary To Gray Code
i. The most significant bit (MSB) of the gray code is always equal
to the MSB of the given binary code.
ii. Other bits of the output gray code can be obtained by xoring
binary code bit at the index and previous index.
• EXAMPLE −convert binary number 111010 into Gray code.
i. The most significant bit (MSB) of the binary code is always equal
to the MSB of the given binary number.
ii. Other bits of the output binary code can be obtained by
checking gray code bit at that index. if current gray code bit is
0, then copy previous binary code bit, else copy invert of
previous binary code bit.
• EXAMPLE − convert Gray code 100111 into binary number.
• so, according above algorithm,
• b5=g5=1=1
• b4=g5⊕g4 =1⊕0 =1
• b3=b4⊕g3 =1⊕0 =1
• b2=b3⊕g2 =1⊕1 =0
• b1=b2⊕g1 =0⊕1 =1
• b0=b1⊕g0 =1⊕1 =0
• so, binary number will be 111010.