badass tutorial on chapter 1 number system
DESCRIPTION
Number systems explained in painstaking detail.TRANSCRIPT

5/28/2018 BADASS Tutorial on Chapter 1 Number System
1/27
Ms Sandhya Rani Dash
_____________________________________________________________________
UNIT 2: NUMBER SYSTEM AND CODES
Structure
2.1 Introduction
2.2 Objectives
2.3 Binary Numbers
2.3.1 BinarytoDecimal conversion
2.3.2 DecimaltoBinary Conversion
2.4 Octal Numbers
2.4.1 OctaltoBinary Conversion2.4.2 BinarytoOctal Conversion
2.4.3 OctaltoDecimal Conversion
2.4.4 DecimaltoOctal conversion
2.5 Hexadecimal Numbers2.5.1 HexadecimaltoBinary Conversion
2.5.2 BinarytoHexadecimal Conversion
2.5.3 HexadecimaltoDecimal Conversion
2.5.4 DecimaltoHexadecimal Conversion2.5.5 Octal to Hexadecimal Conversion
2.5.6 Hexadecimal to Octal Conversion
2.6 Arithmetic Operation
2.7 1s and 2s Complement2.7.1 Subtraction using 1s complement
2.7.2 Subtraction using 2s complement
2.8 9sand 10s Complement
2.8.1 Subtraction using 9,s complement
2.8.2 Subtraction using 10s complement
2.9 Codes
2.9.1 BCD code
2.9.2 Excess3 code
2.9.3 Gray code
2.10 Unit Summary
1.1IntroductionThe study of number system begins with the familiar decimal number system. The
decimal number system consists of ten unique digits 0 to 9. So, its base/radix is 10
(since it involves with 10 symbols).The digits 0 to 9 are used to specify any number.Computers and other digital circuits dont process decimal numbers . They work with
binary numbers which consists of only two digits 0&1.This creates a problem.
Because to represent larger decimal quantities, a very long binary number is required.
So to compress this long string of binary numbers, octal & hexadecimal number
systems are widely used in digital systems .So the knowledge of these number
systems is very essential for understanding, analyzing and designing of digital
systems.

5/28/2018 BADASS Tutorial on Chapter 1 Number System
2/27
This unit discuss about the decimal, binary, octal and hexadecimal numbers. The inter
conversion of these number systems are also explained here. Different types of codes ,
which are commonly used in digital systems and microprocessors have also been
discussed in this unit.
1.2ObjectivesAfter going through this unit you will be able to:
i) Explain different types of number system(Binary, Decimal, and Octal & Hexadecimal)
ii) Convert one number system to another
iii) Appreciate binary arithmetic operation
iv) Define complements (1s, 2s, 9s & 10s complement)
v) Apply use of complements in subtraction
vi) Explain different types of codes and convert a code to binary and vice versa.
2.3 Binary Numbers
Binary number system is extensively used in digital electronics since it uses only one
two symbols 1 & 0. These two digits represent the two voltage levels high or low
in digital electronics. The base (radix) of the binary number system is 2. It is a
positional system, i.e., every position is assigned a specific weight. In digital system
each binary digit is called a bit
A group of 4 bit is called nibble
A group of 8 bit is called byte

5/28/2018 BADASS Tutorial on Chapter 1 Number System
3/27
Representation of Decimal and Binary numbers
The following table represents the decimal number and its corresponding binarynumber
DecimalNumber
Binary NumberB3 B2 B1 B0
0 0 0 0 0
1 0 0 0 1
2 0 0 1 0
3 0 0 1 1
4 0 1 0 0
5 0 1 0 1
6 0 1` 1 0
7 0 1 1 1
8 1 0 0 09 1 0 0 1
2.3.1 Binary to decimal conversion
Binary numbers can be converted into a decimal number by multiplying by the binary
numbers 1 or 0 by their positional weight and adding the product.
For Example
Convert the binary number 11010 to its decimal equivalent
Binary
Number
Conversation of Binary to
decimal
Decimal
Equivalent
11010
1x2 +1x2 +0x2 +1x2 +0x2
=16+8+0+2+0=26
26
2.3.2 Decimal to Binary conversion
Any decimal numbers can be converted into its equivalent binary numbers by
successive division by 2 and keeping the track of the reminders. The division is
continued till the quotient is 0. The number read from bottom to top gives the
equivalent binary number.

5/28/2018 BADASS Tutorial on Chapter 1 Number System
4/27
For example
Convert 26 to its binary equivalent
Decimal
Number
Quotient Remainder Binary
Equivalent
(26)10
26/2 13 0MSB
(11010)13/2 6 1
6/2 3 0
3/2 1 1
1/2 0 1LSB
The decimal fraction is converted to binary fraction by successive multiplication by 2
and keeping the track of integers generated. The multiplication is continuities till the
fraction part of the product is 0. The integers read from top to bottom to get the binary
equivalent.
For example
Convert 0.625 to its binary equivalent
Decimal
Number
Generated
Integer
Binary
Equivalent
0.625
0.625x 2
1.250 1MSB0.1010.250x 2
0.500 0
0.500x 2
1.000 1 LSB
0.000x 2
0.000 0

5/28/2018 BADASS Tutorial on Chapter 1 Number System
5/27
Self Check Exercise1
A. For Q No. 1  5 select the most appropriate alternative from among the four
alternatives given below each question
1. The digital systems usually operate on _______ system.
a) Binary b) decimalc) octal d) hexadecimal
2. The binary system uses power of ______for positional values.
a) 2 b) 8 c) 16 d) 10
3. After counting 0, 1, 10, 11, the next binary number is
a) 12 b) 100 c) 101 d) 110
4. The number 1000 is equivalent to decimal number
a) one thousand b) eight c) four d) sixteen
5. In binary numbers, shifting the binary point one place to the right
a) Multiplies by 2 b) divides by 2
c) Decreases by 2 d) increases by 10
B. Answer the following questions
6. Convert the following decimal numbers to their binary equivalents:
a) 167 b) 72.45 c) 52 d) 163.875
7. How do you convert a decimal number to an equivalent number in any other basesystem?
2.4 Octal Numbers
The base or( radix) of the octal number system is 8.This number system uses 8
different symbols 0,1,2,3,4,5,6,7. Each significant position in an octal no. system has
a positional weight. These weights are given in the ascending powers of 8, i.e 80, 8
1,
82,.etc. respectively.
The binary equivalent of an octal no. must be a group of 3 bits word, since the base of
octal no. system is 8=23.

5/28/2018 BADASS Tutorial on Chapter 1 Number System
6/27
2.4.1Octal to Binary conversion
Octal numbers can be converted into equivalent binary numbers by replacing each
octal digit by its 3 bit equivalent binary.
Example: convert (3702)8to a binary number.
(3702)8= 3 7 0 2011 111 000 010
The number (3702)8= (011111000010)2
= (11111000010)2
On the most significant digit, leading zeros can be suppressed .i.e. 3 can be written as
11 instead of 011.
2.4.2Binary to octal conversion
To convert from binary to octal back, the reverse procedure is used .i.e. divide the
whole binary string into groups of 3 bits. Then starting from LSB and moving towards
MSB, convert each group of 3 bits into the corresponding octal digit.
For Example
Convert (10101011111)2to an octal number.
Solution: 10 101 011 111
2 5 3 7
Therefore (10101011111)2= (2537)8
2.4.3 Octal to decimal conversion
Any octal number can be converted into its equivalent decimal number by multiplyingeach digit of the octal number by the weight of its position and then adding the
products.
Example
Convert (4257.14)8 into its equivalent decimal number.
Solution
(4257.14)8=4 x83+2 x82+5 x 81+7 x80+ 1 x 81+4 x 82

5/28/2018 BADASS Tutorial on Chapter 1 Number System
7/27
=2048 + 128 + 40 + 0.125 + 0.0625
= (2216.1875)10
2.5.4 Decimal to octal conversion
The octal equivalent of a decimal no. can be obtained by dividing a given decimal
number by 8 repeatedly until a quotient 0 is obtained. The process is exactly the same
as the method explained earlier. The following example illustrates the conversion
from decimal to octal.
For Example
Convert (115.1875)10to octal no.
Integer Part Quotient Reminder Octal
Equivalent
115
115/8 14 3 MSB
(163)814/8 1 6
1/8 0 1 LSB
Fractional
Part
Result Integral Part Octal
Equivalent
(0.1875)10
0.1875x8 1.5000 1
(0.14)80.5000x8 4.000 4
Therefore (115.1875)10= (163.14)8
Self Check Exercise 2
A. For Q No. 8 11 select the most appropriate alternative from among the four
alternatives given below each question
8. The number 128is equivalent to decimal
a) 12 b) 20 c) 10 d) 4
9. The number 10001012is equivalent to octal
a) 54 b) 45 c) 37 d) 25
10. The number 178 is equivalent to binary
a) 11 b) 1110 c) 10000 d) 1111

5/28/2018 BADASS Tutorial on Chapter 1 Number System
8/27
11. Which of the following is NOT an octal number?
a) 19 b) 77 c) 15 d) 101
B. Answer the following questions
12. Convert each of the octal numbers to binary.
a)158 b) 1738 c) 367.528 d) 1578
13. Convert the following decimal no. to octal no. then to binary.
a)59 b) 0.58 c) 64.2 d) 199.3
2.5 Hexadecimal Numbers
The hexadecimal number system is the most popular means of direct data entry and
retrieval in digital system. The base of hexadecimal number system is 16 and uses 16
symbols, namely, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F. The symbol A to F
represents the decimal 10 to 15 respectively.
Since its base is 16= 24, every 4 bit binary digit combination can be represented by
one hexadecimal digit. Each significant position in an hexadecimal number has a
positional weight. These weights are given in the ascending powers of 16. i.e., 160,
161,
162, . etc
2.5.1 Hexadecimaltobinary conversion
The conversion of Hexadecimal to Binary is the reverse process of conversion from
Binary to Hexadecimal as explained above. i.e. each hexdigit is replaced by its 4bit
binary group.
For example
Convert (2DAC)16 to Binary
(2DAC)16 = 2 D A C0010 1101 1010 1100
= (10110110101100)2

5/28/2018 BADASS Tutorial on Chapter 1 Number System
9/27
2.5.2 Binary to hexadecimal conversion
To convert a binary no. to a hexadecimal no., divide the whole binary string in to
groups of 4 bits each and then replace each 4 bit group by the equivalent hexadecimal
digit
For example
Convert (1010100100)2to hexadecimal no.
(1010100100)2 =0010 1010 0100
= 2 A 4= (2A4)16
2.5.3 Hexadecimal to decimal conversion
To Convert a Hexadecimal number to Decimal multiply each digit in the Hex no. by
its position weight and take the summation of all these product terms
For Example
Convert to (5A6)16 to Decimal
(5A6)16 =5 x 162 +
10 x 161+ 6 x 16
0
= 1280 + 160 + 6
= (1446)10
2.5.4 Decimal to hexadecimal conversion
A decimal no. can be converted to Hexadecimal no. by successively dividing the
given decimal no. by 16 till the quotient is 0.
For Example
Convert (2598)10to Hexadecimal
DecimalNumber
Quotient Remainderin Decimal
HexadecimalNo.
HexadecimalEquivalent
(2598)10
2898/16 162 6 6
(A326)16162/16 10 2 2
10/16 0 10 A
Therefore (2598)10= (A326)16

5/28/2018 BADASS Tutorial on Chapter 1 Number System
10/27
2.5.5 Octal to hexadecimal conversion
To convert an octal no. to hexadecimal the easiest method is to first convert the hex
no. to its binary equivalent and then the binary no. to hexadecimal. It will be clear
from the example given below.
For Example:
Convert (756.402)8to hexadecimal no.
(756.402)8 = 7 5 6 . 4 0 2
= 111 101 110 100 000 010
For the integer part, group the binary bits into 4 from LSB to MSB and for the
fractional part group the bits from the MSB to LSB
(756.402)8 = 0001 1110 1110 . 1000 0001 000= 1 E E 8 1 0
= (1EE.810)16
2.5.6 Hexadecimal to octal conversion
To convert a hexadecimal no. to octal, the simple way is to first convert binary no. tooctal.
For Example: Convert (56)16to Octal no.
(56)16= 0101 0110
= (01010110)2= 01 010 110
= 1 2 6= (126)8
Self Check Exercise 3
A. For Q No. 14 19, Select the most appropriate alternative from among the
four alternatives given below each question
14. The radix/base of the hexadecimal no. system is
a)10 b)16 c) 8 d) 2
15. The symbol E represents the decimal
a)13 b)15 c) 14 d) 12
16. The number 2D16is equivalent to binary

5/28/2018 BADASS Tutorial on Chapter 1 Number System
11/27
a) 0010 1101 b) 1101 0010 c) 0011 1101 d) 010 0011
17. Hexadecimal number system is used as a shorthand language for representing
__________ numbers.
a) decimal b)binary c) octal d) large
18.The binary equivalent of A16is
a)1010 b) 1011 c) 1000 d) 1110
19. The number 4716is equivalent to octal
a) 701 b) 137 c) 401 d) 107
B. Answer the following questions
20. What are the advantages of aa) Binary no. system b) Hexadecimal no. system
21. Convert the following hexadecimal numbers to binary.
a) 4916 b) 32416 c) 4BAC16 d) 3A9.BD16
2.6 Arithmetic Operation
Binary arithmetic is much simpler than decimal arithmetic because here only two
digits 0&1 are involved. Arithmetic operations in a computer are done in its
arithmetic unit by using binary numbers. The basic arithmetic operations are , addition
,subtraction, multiplication ,division.
These operations are performed by digital logic circuits called the adder, sub tractor ,
multiplier and divider.
The arithmetic rules for Addition, Subtraction, Multiplication, and Division of binary
numbers are given below.
Addition Subtraction Multiplication Division
0+0=0 00=0 0 x 0=0 0/1=0
0+1=1 10=0 0 x 1=0 1/1=1
1+0=1 11=0 1 x 0=0 0/0=0
1+1=10 101=1 1 x 1=1 1/0=not allowed

5/28/2018 BADASS Tutorial on Chapter 1 Number System
12/27
Self Check exercise 4
A. For Q No. 22 26 Select the most appropriate alternative from among the fouralternatives given below each question
22. The binary addition 1 + 1 + 1 gives
a) 111 b) 10 c) 110 d) 11
23. The cumulative addition of the four binary bits ( 1 + 1 + 1 + 1 ) gives
a) 1111 b) 111 c) 100 d) 1001
24. The result of binary subtraction (100011) is
a)111 c) 111 c) 011 d)001
25. The result of binary multiplication 1112 x 102 is
a) 1101 b) 0110 c) 1001 d) 1110
26.The binary division 110002/1002 gives
a) 110 b) 1100 c) 11 d) 101
B. Answer the following questions
27. Subtract the following groups of binary numbers.
a) 1111011011 b) 10110.1  1100.01 c) 101.101100.1
28. Add the following groups of binary numbers using the binary addition method.
a) 1010 + 1011 b) 1011.0111 + 1101.101 c) 1110.1011 + 1001.1110
2.7 1s and 2sComplement
There are two complement forms used in digital systems to represent signed numbers.These are 1s complement and 2s complement form. These two forms are used to
represent negative numbers. Most digital computers do subtraction by the 2scomplement method .The advantage of performing subtraction by the complement
method is reduction in the hardware. Instead of having separate digital circuits foraddition and subtraction, only adding circuits are needed .i.e. subtraction is also
performed by adders only.
To take the 1s complement of a binary no., simply change all 1s to 0s and all 0s to
1s

5/28/2018 BADASS Tutorial on Chapter 1 Number System
13/27
For Example
The 1s complement of 110010 is 001101
Similarly the 2s complement of a binary no. can be obtained by adding 1 to its 1scomplement
For Example
Find the 2s complement of 10110
1s complement of 10110= 01001
For obtaining 2s complement of 10110, you have to add 1 to 01001(1s complement
of 10110)
i.e, 1+ 01001= 01010
2.7.1 Subtraction using 1s complement
The subtraction using 1s complement can be obtained by the following methods:
Take the 1s complement of the subtrahend (smaller number). Add this to the minuend (larger number).
If a carry is generated, it indicates that the answer is positive. Add the carry tothe result. This carry is called the endaround carry (EAC).
If no carry is generated, then the answer is negative. Take the 1s complementof the original addition and change the sign.
For Example 1
Subtract (1011)2from (1110)2using 1s complement method.
1 1 1 0 (+)
1s complement 0 1 0 0____________________
Carry 1 0 0 1 0
Add Carry 1____________________
0 0 1 1
The answer is (0011)2

5/28/2018 BADASS Tutorial on Chapter 1 Number System
14/27
For Example 2
Subtract (11000)2from (101)2 using 1s complement method
1 0 1 (+)
1s complement 0 0 1 1 1___________________________
No carry 0 1 1 0 0
The answer isve, since no carry is obtained. Si the answer is the 1s complement ofthe 01100 and is in opposite sign i.e, 10011
2.7.2 Subtraction using 2s complement
2s complement subtraction can be obtained by the following methods.
Take the 2s complement of the subtrahend (smaller number).Add it to the minuend (larger number).Presence of a Carry indicates that the answer is positive. Omit the carry.Absence of a carry indicates that the answer is negative. Take the 2s
complement of the original addition and change the sign.
For Example
Subtract (1011)2from (1110)2using 2s complement method
1 1 1 0 (+)
2s complement 0 1 0 1_______________________________
Carry 1 0 0 1 1
The carry is ignored. Thus the answer is (0011)2
For Example 2
Subtract (101002from (1000)2using 2s complement method
1 0 0 0 (+)
2s complement 0 1 1 0___________________________________
No Carry 1 1 1 0
No carry is obtained. The answer is the 2s complement of (1110) 2and is in opposite
sign.
i.e, (0010)2

5/28/2018 BADASS Tutorial on Chapter 1 Number System
15/27
2.8 9s and 10s Complement
9s complement
The 9s complement of a decimal number can be obtained by subtracting each digit in
the number from 9,i.e a digit plus its 9s complement equals to 9. The 9s complementof decimal digits 0 to 9 are listed below.
Decimal No. 9s Complement
0 0
1 8
2 7
3 6
4 5
5 4
6 3
7 28 1
9 0
For Example
Find the 9scomplement of each of the following decimal no.s
a) 15 b)135
Subtract each digit in the no. from 9 to get the 9s complement
a) 9915 = 84 (9s complement of 15)
b) 999135 = 864 (9s complement of 135)
10s complement
The 10s complement of a decimal no. i equal to its 9s complement + 1
For Example
Convert the following decimal no. in to its 10s complement form
a) 18 b) 152
a) 9918= 81 (9s complement of 18)
81+1= 82(10s complement of 18)
b) 999152= 847 (9s complement of 152)
847+1 = 848 (10s complement of 152)

5/28/2018 BADASS Tutorial on Chapter 1 Number System
16/27
2.8.1 Subtraction using 9s complement
Subtraction of a smaller number from a larger number us ing 9s complement
Steps:
Take the 9s complement of the smaller number Add the 9s complement to the larger number Carry indicates that the answer is positive. Add the carry to the list significant
digit
If there is no carry the answer is negative. Take the 9s complement of theresult and change the sign
For Example
Subtract 143 from 363 using 9s complement
Direction Subtraction 9s complement subtraction
363 363 143 9s complement of 143 + 856
________ _____________220 Carry 1 219
Add carry to the result 1+ 219= 220
The answer is positive. i.e, 220
For Example
Subtract 745 from 245 using 9s complement
Direction Subtraction 9s complement subtraction
245 245
 745 9s complement of 745 + 254________ _____________
500 Carry 0 499
9s complement of 499 = 999499= 500
No carry indicates that the answer is negative. i.e, 500

5/28/2018 BADASS Tutorial on Chapter 1 Number System
17/27
2.8.2 Subtraction using 10s complement
It is analogous to the often used 2s complement method in binary subtraction. In thismethod the minuend is added to the 10s complement of the subtrahend and the carry
is ignored.
For Example
a) Subtract 54 from 88 using 10s complement method
Direction Subtraction 10s complement subtraction
88 88 54 10s complement of 54 + 46
________ _____________34 Carry 1 34
Ignore the carry. The answer is positive i.e, 34
For Example
b) Subtract 813 from 432 using 10scomplement method
Direction Subtraction 10s complement subtraction
432 432
 813 10s complement of 813 + 187________ _____________381 Carry 0 619
10s complement of 619 = 381
Since there is no carry, the answer is negative. i.e, 381
Self Check Exercise 5
A. For Q No. 29 33 select the most appropriate alternative from among the four
alternatives given below each question
29. The chief reason why digital computers use complemental subtraction is that it
a) Simplifies their circuitry b) is a very simple processc) can handle negative numbers easily. d) Avoids direct subtraction
30. The 1s complement of 10102is
a) 0110 b) 0101 c) 1110 d) 0011

5/28/2018 BADASS Tutorial on Chapter 1 Number System
18/27
31. The 2s complement of 10002is
a) 0111 b) 0101 c) 1000 d) 0001
32. The 9s complement of 19 is
a) 91 b) 99 c) 80 d) 81
33.The 10s complement of 46 is
a) 54 b) 53 c) 45 d) 35
B. Answer the following questions
34. How can negative no be represented? Distinguish between 1s complement and2s complement
35.Distinguish between 9s complement and 10s complement ?
2.9 Codes
We are very comfortable with the decimal number system, but digital systems like
computers & other digital circuits process the data in the binary format. So various
binary codes are used to represent the data. A code is a symbolic representation of
discrete information, which may be present in the form of numbers, letters or physical
quantities. The information used in every code is represented in binary form. The
binary code can be classified into two types of codes, i.e. numeric codes and
alphanumeric codes. Alphanumeric codes represent alphanumeric information, i.e.
letters of the alphabet, and decimal numbers as a sequence of 0s and 1s. An example
of alphanumeric cod e is the ASCII code (American Standard Code for Information
Interchange). Numeric code represents numeric information, i.e. only numbers as a
series of 0s and 1s.An example of the numeric code is the Binary coded decimal
(BCD) code which is used to represent decimal digits.
Codes are also used for error detection and error correction purpose. Since when
digital signals are transmitted from one location to another location, errors may occur
due to electrical noise. Various types of codes are discussed below.

5/28/2018 BADASS Tutorial on Chapter 1 Number System
19/27
2.9.1 BCD (or) 8421 code
A Binary Coded Decimal (BCD) is one in which, decimal digits are encoded by their
natural binary equivalentsone at a timeinto groups of four bits.
For example (25)10is represented by [0010 0101] using BCD code, rather than(10001)2. It is a positional weight code. Each position of a number represents a
specific weight.
These codes are also known as 8421 code or simply BCD code. The number 8421
indicates the binary weights of the four bits. i.e. the weights of the first (right most)
position is 20=1, 2
1=2, 2
2=4, 2
3=8.Replacing from left to right, the weights are 842
1,and hence it is called 8421 code.
The disadvantage of BCD code is that it requires more no. of bits to code a decimal
number. But the ease of conversion between the BCD code to decimal number and
vice versa is the main advantage of this code, which makes it useful and popular code
for input,output operations in digital systems .To convert any decimal number in to
BCD ,each decimal digit should be replaced by the appropriate 4bit code.
The following table summarizes the binary and BCD codes for the decimal numbers
0 to 15.
Decimal numbers Binary number Binary Coded
Decimal(BCD)
0 0000 0000
1 0001 0001
2 0010 0010
3 0011 0011
4 0100 0100
5 0101 0101
6 0110 0110
7 0111 0111
8 1000 1000
9 1001 1001
10 1010 0001 0000

5/28/2018 BADASS Tutorial on Chapter 1 Number System
20/27
11 1011 0001 0001
12 1100 0001 0010
13 1101 0001 0011
14 1110 0001 0100
15 1111 0001 0101
For Example
Convert (3906)10to BCD.
3 9 0 6
11 1001 00000 0110
Therefore (3906)10=11100100000110
Note: Leafing zeros are added to ensure that each digit is represented by four bits .The
leading zeros can be suppressed on the most significant digit.
Conversion flow chart
The flow chart summarizes the conversions that have been discussed so far. There is
no line directing from octal to BCD ,because that direct conversion was not presented.
To convert from octal to BCD , convert to binary, then decimal, then BCD.
2.9.2 Excess3 code
The XS3 code is a nonweight code. This means each position with in a binary
number isnt assigned affixed value. This code is a self complementing code, which
HEXADECIMAL BINARY DECIMAL
OCTAL BCD

5/28/2018 BADASS Tutorial on Chapter 1 Number System
21/27
means 1s complement of the coded number yields 9s complement of the number
itself. As the name indicates, XS3 code represents a decimal number ,in binary form,
as a number greater than 3. An XS3 code is obtained by adding 3 to a decimal
number, then convert it into its equivalent BCD code.
For Example: A decimal 4 can be coded, by adding 3 into4; in order to obtain 7.7 is
then encoded in its equivalent 4 bit binary code 0111.
So 0111 is the XS3 code of the decimal number 4.
Or it can also be obtained directly in another way by adding binary equivalent of 3 to
the natural BCD code of the digit.
i.e. Decimal 4 is coded as 0100+0011=0111 in XS3 code.
For Example
Convert (463)10into its XS3 code.
Given decimal number 4 6 3
Add 3 to each bit +3 +3 +3
_________________
Sum 7 9 6
Converting the above sum into its BCD code, we have
Sum 7 9 6
BCD 0111 1001 0110
Hence, the XS3 code for (463)10is 0111 1001 0110
The following table summarizes the BCD, XS3 code and 9s complement
representation for decimal digits.
Decimal BCD code XS3 code 9s complement
0 0000 0011 1100
1 0001 0100 1011
2 0010 0101 1010
3 0011 0110 1001
4 0100 0111 1000
5 0101 1000 0111

5/28/2018 BADASS Tutorial on Chapter 1 Number System
22/27
6 0110 1001 0110
7 0111 1010 0101
8 1000 1011 0100
9 1001 1100 0011
2.9.3 Gray codes
The gray code isnt a weighted code and isnt suitable for arithmetic operations, but
finds application in input/output devices and in some types of analog to digital
converters. Gray code is a cyclic code which has a special property of containing two
successive code words differ in one bit position only, i.e . it is a unit distance code. It
is also called as the reflected code.
Conversion of a binary number to gray code
Keep the first bit of the gray code is the same as the first bit of the binarynumber.
The second bit of the gray code equals to the sum of first and second bit of thebinary number. Discard the carry if it is generated from the sum.
The third bit of the gray cod equals to the sum of second and third bit of thebinary number and so on.
Example: Convert the binary (110010)2to its gray code.
Solution:
1 + 1 + 0 + 0 + 1 + 0 [Binary]
1 0 1 0 1 1 [Graycode]
Conversion from gray code to binary
Conversion of a Gray code into its binary form involves the reverse of the procedure
as given below
i) The first binary bit (MSB) is the same as that of the first Gray code bit
ii) If the second Gray bit is zero, the second binary bit is the inverse of its first binarybit.
iii) Step 2 is repeated for each successive bit

5/28/2018 BADASS Tutorial on Chapter 1 Number System
23/27
For Example
Convert [1010111]Gto binary
Solution:
1 0 1 0 1 1 1 Gray
1 1 0 0 1 0 1 Binary
Therefore [1010111]G = [1100101]2
Self Check Exercise 6
A. For Q No. 36 41 Select the most appropriate alternative from among the four
alternatives given below each question
36. BCD code is
a) nonweighted code b) the same thing as binary numbers
c) a binary code d) an alphanumeric code
37. Which of the following 4bit combinations is/are invalid in the BCD code?
a) 1010 b) 0010 c) 0101 d) 1000
38. In XS3 code each coded number is ________ than in BCD
a) four larger b) three smaller c) three larger d) much larger
39. The XS3 code of 01012 is
a) 1001 b) 1000 c) 1001 d) 0110
40. Gray code is
a) nonweighted code b) weight code
c) a binary code d) an alphanumeric code
41. The gray code of 01112is
a) 1000 b) 1001 c) 0101 d) 0100

5/28/2018 BADASS Tutorial on Chapter 1 Number System
24/27
B. Answer the following questions
42. What is a BCD code? What are its advantages and disadvantages?
43. Define the XS3 code and gray code. Why these are important?
2.9 Unit Summary
This unit explains the various number systems, which are widely used in digital
systems. The general properties of number system, methods of conversion from one
number system to another and the rules of arithmetic operations are discussed.
Various complement methods like 1s complement, 2s complement, 9s
complement& 10s complement are introduced to make the subtraction easier. With
the application of these methods the subtraction can be achieved by adding the
complement of the subtrahend to the minuend. Different codes are used in digital
systems which may be in the form of numbers, letters or physical quantities. Some of
the more commonly used codes like BCD, XS3Code, gray code are introduced. The
knowledge of these number systems & codes is very essential for the effective
understanding of digital systems
Answers to Check Your Progress
1. (a) 2. (a) 3. (b) 4. (b) 5. (a)
6. a)101001112 b) 1001000.011102 c) 1101002 d) 10100011.1112
7. A decimal number can be converted to an equivalent no. in any other base system
with the base b by successively dividing the decimal no by b. In this method, the
reminders are read from bottom to top. Similarly a decimal fraction can be converted
to an equivalent no. in any other base system with the base b by successively
multiplying the decimal no by b. In this method, the integers to the left of the radix
point are read from top to bottom.
8). (c) 9. (b) 10. (d) 11. (a)
12. a) 00012 b) 001 111 0112 c) 011 110 111.101 0102 d) 001 101 1112
13 a ) 1110112 b) 0. 100 101 000 1112 c) 001 000 000.001 1002
d) 011 000 111.010 011 0012

5/28/2018 BADASS Tutorial on Chapter 1 Number System
25/27
14. (a) 15. (c) 16. (a) 17. (a) 18.(a) 19. (d)
20. The advantages of binary no. system is that, it is very simple, because it consists
of only two digits, i.e.0&1. So it is useful in digital computers ,since the switching
circuits used in these computers use two state devices such as transistors ,diodes etc.
Hexadecimal no. systems are used to compress the long strings of binary numbers.It is
the most popular means of direct data entry and retrieval in digital systems.
21. a ) 0100 10012 b) 0011 0010 01002 c) 0100 1011 1010 11002
d) 0011 1010 1001. 1011 11012
22. (d) 23. (c) 24. (d) 25. (d) 26. (a)
27.a) 0011 b) 1010.01 c) 1.001
28.a) 10101 b) 11001.0001 c) 11000.1001
29. (a) 30. (b) 31. (c) 32. (c) 33. (a)
34.Negative numbers can be represented in sign magnitude form ,i.e. MSB representsthe sign bit (0 for positive and 1 for negative) and the remaining bits represent the
magnitude of the no. Negative numbers can also be represented by the 1s
complement form, or in 2s complement form
1s complement can be easily obtained using an inverter. The 2s complement can beobtained by first obtaining the 1s complement and then adding (1) to it
35. The 9s complement of a decimal no. can be obtained by subtracting each digit of
that decimal no. from 9. The 10s complement of a decimal no. is obtained by adding
a 1 to its 9s complement.
36. (c) 37. (a) 38. (c) 39. (b) 40. (a) 41. (d)
42. The BCD code uses the binary no. system to specify the decimal numbers 0 to 9.
In this code each decimal digit, 0 through 9 is coded by 4bit binary no. It is also
called as the 8421 code. The main advantage of this code is its ease of conversion to
and from decimal and the disadvantage of this BCD code is that, arithmetic

5/28/2018 BADASS Tutorial on Chapter 1 Number System
26/27
operations are more complex then they are in pure binary. It is less efficient than the
pure binary , in the sence that it requires more bits.
43. A XS3 code is a BCD code formed by adding 3(0011) to the binary equivalent of
the decimal no.
A Gray code is one, in which only one bit changes between successive numbers. It is
also called! #$%& '%(&!$)* )+'*
The XS3 code helps in computing mathematical operations in digital computers.
The Gray code is useful for its ease of conversion to and from binary. It is used in
instrumentation and data acquisition systems where linear or angular displacement is
measured. It is used in I/O devices, A/D converters and other peripheral devices.
References
Bignell, J and Donovan, R. (1989) Digital Electronics, Delmar Publishers Inc. New
York
Jain, R. P. (2007) Modern Digital Electronics; Third Edition; Tata McGrawHillPublishing Company Limited; New Delhi
Kumar, A. A. (2004) Fundamentals of Digital Circuits; Seventh Edition; Eastern
Economy Editions; Prentice Hall India Pvt. Ltd; New Delhi
Mano, M. M. (2006) digital Logic and Computer Design; Second Edition; EasternEconomy Editions; Prentice Hall India Pvt. Ltd; New Delhi
Malbert, A. B. and Leach, D. P. (1993) Digital Principles and Applications, Tata Mc
Graw hill Publishing Company Limited, New Delhi
Salivahanan, S. and Arivazhagan, S. (2006) Digital Circuits and Design, VikasPublishing House Pvt Ltd, Delhi
Srinivasan, P. (2007) National Programme Technology Enhanced Learning Video
Lectures on Introduction to Digital Circuits and System. Lecture I & II

5/28/2018 BADASS Tutorial on Chapter 1 Number System
27/27
Unit End Exercise
1. State the common features between different number system.
2. What are meant by 1s and 2s complement of a binary number?
3. Explain the rules for binary subtraction using 1s and 2s complement methods.
4. Compare BCD and Binary systems of coding
5. How do you convert a binary number to a Gray number and vice versa.