You are on page 1of 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 Binary-to-Decimal conversion 2.3.2 Decimal-to-Binary Conversion 2.4 Octal Numbers 2.4.1 Octal-to-Binary Conversion 2.4.2 Binary-to-Octal Conversion 2.4.3 Octal-to-Decimal Conversion 2.4.4 Decimal-to-Octal conversion 2.5 Hexadecimal Numbers 2.5.1 Hexadecimal-to-Binary Conversion 2.5.2 Binary-to-Hexadecimal Conversion 2.5.3 Hexadecimal-to-Decimal Conversion 2.5.4 Decimal-to-Hexadecimal Conversion 2.5.5 Octal to Hexadecimal Conversion 2.5.6 Hexadecimal to Octal Conversion 2.6 Arithmetic Operation 2.71sand2sComplement 2.7.1Subtractionusing1scomplement 2.7.2Subtractionusing2scomplement 2.89s and10sComplement 2.8.1 Subtraction using 9,s complement 2.8.2Subtractionusing10scomplement 2.9 Codes 2.9.1 BCD code 2.9.2 Excess-3 code 2.9.3 Gray code 2.10 Unit Summary

1.1 Introduction The 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. Computersandotherdigitalcircuitsdontprocessdecimalnumbers . 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.

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.2 Objectives After 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)Definecomplements(1s,2s,9s&10scomplement) 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 repr esentthetwovoltagelevelshighorlow 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 eachbinarydigitiscalledabit A groupof4bitiscallednibble Agroupof8bitiscalledbyte

Representation of Decimal and Binary numbers The following table represents the decimal number and its corresponding binary number Decimal Number 0 1 2 3 4 5 6 7 8 9 B3 0 0 0 0 0 0 0 0 1 1 Binary Number B2 B1 0 0 0 0 1 1 1` 1 0 0 0 0 1 1 0 0 1 1 0 0 B0 0 1 0 1 0 1 0 1 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 11010 Conversation of Binary to decimal 4 3 1x2 +1x2 +0x22+1x21+0x20 =16+8+0+2+0 =26 Decimal Equivalent 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.

For example Convert 26 to its binary equivalent Decimal Number 26/2 (26)10 13/2 6/2 3/2 1/2 Quotient 13 6 3 1 0 Remainder 0-MSB 1 0 1 1-LSB (11010) Binary Equivalent

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 0.625 0.625x 2 1.250 0.250x 2 0.500 0.500x 2 1.000 0.000x 2 0.000 Generated Integer 1-MSB 0.101 0 1- LSB 0 Binary Equivalent

Self Check Exercise-1 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 c) Decreases by 2 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 b) divides by 2 d) increases by 10

7. How do you convert a decimal number to an equivalent number in any other base system? 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, 81, 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.

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)8 to a binary number. (3702)8 = 3 011 7 111 0 000 2 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)2 to an octal number. Solution: 10 2 101 5 011 3 111 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 multiplying each 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 8-1+4 x 8-2

=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)10 to octal no. Integer Part 115 115/8 14/8 1/8 Quotient 14 1 0 Result 0.1875x8 0.5000x8 1.5000 4.000 Reminder 3 MSB 6 1 LSB Integral Part 1 4 Octal Equivalent (163)8 Octal Equivalent (0.14)8

Fractional Part (0.1875)10

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 128 is equivalent to decimal a) 12 b) 20 c) 10 d) 4

9. The number 10001012 is 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

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., 16 0, 161, 162,.etc 2.5.1 Hexadecimal-to-binary 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 4-bit binary group. For example Convert (2DAC)16 to Binary (2DAC)16 = 2 D A C 0010 1101 1010 1100 = (10110110101100)2

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)2 to hexadecimal no. (1010100100)2 = 0010 = 2 = (2A4)16 1010 A 0100 4

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 160 = 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)10 to Hexadecimal Decimal Number (2598)10 Quotient Remainder Hexadecimal Hexadecimal in Decimal No. Equivalent 2898/16 162 6 6 162/16 10/16 10 0 2 10 2 A (A326)16

Therefore (2598)10= (A326)16

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)8 to hexadecimal no. (756.402)8 = 7 = 111 5 6 101 110 . 4 100 0 2 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 = 1 E = (1EE.810)16 1110 E . 1000 8 0001 1 000 0

2.5.6 Hexadecimal to octal conversion To convert a hexadecimal no. to octal, the simple way is to first convert binary no. to octal. For Example: Convert (56)16 to 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. ThesymbolErepresentsthedecimal a)13 b)15 c) 14 d) 12

16. The number 2D16 is equivalent to binary

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 A16 is a)1010 b) 1011 c) 1000 d) 1110

19. The number 4716 is equivalent to octal a) 701 b) 137 c) 401 d) 107

B. Answer the following questions 20. What are the advantages of a a) 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 0+0=0 0+1=1 1+0=1 1+1=10 Subtraction 0-0=0 1-0=0 1-1=0 10-1=1 Multiplication 0 x 0=0 0 x 1=0 1 x 0=0 1 x 1=1 Division 0/1=0 1/1=1 0/0=0 1/0=not allowed

Self Check exercise 4 A. For Q No. 22 -26 Select the most appropriate alternative from among the four alternatives 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 (100 011) 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) 11110 11011 b) 10110.1 - 1100.01 c) 101.101 100.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.71s and 2s Complement 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 2s complement method .The advantage of performing subtraction by the complement method is reduction in the hardware. Instead of having separate digital circuits for addition and subtraction, only adding circuits are needed .i.e. subtraction is also performed by adders only. Totakethe1scomplementofabinaryno.,simplychangeall1sto0sandall0s to 1s

For Example The1scomplementof110010is001101 Similarlythe2scomplementofabinaryno.canbeobtainedbyadding1toits1s complement For Example Findthe2scomplementof10110 1scomplementof10110=01001 Forobtaining2scomplementof10110,youhavetoadd1to01001(1scomplement of 10110) i.e, 1+ 01001= 01010 2.7.1Subtractionusing1scomplement Thesubtractionusing1scomplementcanbeobtainedbythefollowingmethods: Takethe1scomplementofthesubtrahend (smaller number). Add this to the minuend (larger number). If a carry is generated, it indicates that the answer is positive. Add the carry to the result. This carry is called the end-around carry (EAC). If no carry is generated, then the answer is negat ive.Takethe1scomplement of the original addition and change the sign. For Example 1 Subtract (1011)2 from (1110)2 using1scomplementmethod. 1 1scomplement Carry Add Carry 1 1 1 0 (+)

0 1 0 0 ____________________ 0 0 1 0 1 ____________________ 0 0 1 1

The answer is (0011)2

For Example 2 Subtract (11000)2 from (101)2 using1scomplementmethod 1 0 1 (+)

1scomplement 0 0 1 1 1 ___________________________ No carry 0 1 1 0 0 The answer is ve, since no carry is obtained. Si the answer is t he1scomplementof the 01100 and is in opposite sign i.e, -10011 2.7.2Subtractionusing2scomplement 2scomplementsubtractioncanbeobtainedbythefollowingmethods. Takethe2scomplementofthesubtrahend(smallernumber). Add it to the minuend (larger number). Presence of a Carry indicates that the answer is positive. Omit the carry. Absenceofacarryindicatesthattheanswerisnegative.Takethe2s complement of the original addition and change the sign. For Example Subtract (1011)2 from (1110)2 using2scomplementmethod 1 2scomplement Carry 1 1 0 (+)

0 1 0 1 _______________________________ 1 0 0 1 1

The carry is ignored. Thus the answer is (0011) 2 For Example 2 Subtract (101002 from (1000)2 using2scomplementmethod 1 2scomplement No Carry 0 0 0 (+)

0 1 1 0 ___________________________________ 1 1 1 0

Nocarryisobtained.Theansweristhe2scomplementof(1110) 2 and is in opposite sign. i.e, -(0010)2

2.8

9sand10sComplement

9scomplement The9scomplementofadecimalnumbercanbeobtainedbysubtractingeachdigitin thenumberfrom9,i.eadigitplusits9scomplementequalsto9.The9scomplement of decimal digits 0 to 9 are listed below. Decimal No. 0 1 2 3 4 5 6 7 8 9 For Example Findthe9scomplementofeachofthefollowingdecimalno.s a) 15 b)135 9sComplement 0 8 7 6 5 4 3 2 1 0

Subtracteachdigitintheno.from9togetthe9scomplement a) 99 15 =84(9scomplementof15) b) 999 135=864(9scomplementof135) 10scomplement The10scomplementofadecimalno.iequaltoits9scomplement+1 For Example Convertthefollowingdecimalno.intoits10scomplementform a) 18 b) 152

a) 99-18=81(9scomplementof18) 81+1=82(10scomplementof18) b) 999-152=847(9scomplementof152) 847+1=848(10scomplementof152)

2.8.1Subtractionusing9scomplement Subtraction of a smaller number from a larger number us ing9scomplement Steps: Takethe9scomplementofthesmallernumber Addthe9scomplementtothelargernumber 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 the9scomplementofthe result and change the sign For Example Subtract143from363using9scomplement Direction Subtraction 363 - 143 ________ 220 9scomplementsubtraction 9scomplementof143 Carry Add carry to the result 363 + 856 _____________ 1 219 1+ 219= 220

The answer is positive. i.e, 220 For Example Subtract745from245using9scomplement Direction Subtraction 245 - 745 ________ -500 9scomplementsubtraction 9scomplement of 745 Carry 9scomplementof499 245 + 254 _____________ 0 499 = 999-499= 500

No carry indicates that the answer is negative. i.e, -500

2.8.2Subtractionusing10scomplement It is analogous totheoftenused2scomplementmethodinbinarysubtraction.Inthis methodtheminuendisaddedtothe10scomplementofthesubtrahendandthecarry is ignored. For Example a)Subtract54from88using10scomplementmethod Direction Subtraction 88 - 54 ________ 34 10scomplementsubtraction 10scomplementof54 Carry 88 + 46 _____________ 1 34

Ignore the carry. The answer is positive i.e, 34 For Example b)Subtract813from432using10s complement method Direction Subtraction 432 - 813 ________ -381 10scomplementsubtraction 10scomplementof813 Carry 432 + 187 _____________ 0 619

10scomplementof619=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 process c) can handle negative numbers easily. d) Avoids direct subtraction 30. The 1scomplementof10102 is a) 0110 b) 0101 c) 1110 d) 0011

31. The 2scomplementof10002 is a) 0111 b) 0101 c) 1000 d) 0001

32.The9scomplementof19is a) 91 b) 99 c) 80 d) 81

33.The10scomplement of 46 is a) 54 b) 53 c) 45 d) 35

B. Answer the following questions 34. Howcannegativenoberepresented?Distinguishbetween1scomplementand 2scomplement 35.Distinguishbetween9scomplementand10scomplement? 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.

2.9.1 BCD (or) 8421 code A Binary Coded Decimal (BCD) is one in which, decimal digits are encoded by their natural binary equivalents-one at a time-into 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, 21=2, 22=4, 23=8.Replacing from left to right, the weights are 8-4-21,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 4-bit code. The following table summarizes the binary and BCD codes for the decimal numbers 0 to 15. Decimal numbers 0 1 2 3 4 5 6 7 8 9 10 Binary number 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 Binary Coded Decimal(BCD) 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 0001 0000

11 12 13 14 15 For Example Convert (3906)10 to BCD. 3 11 9 1001

1011 1100 1101 1110 1111

0001 0001 0001 0010 0001 0011 0001 0100 0001 0101

0 00000

6 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 HEXADECIMAL BINARY DECIMAL

OCTAL

BCD

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 Excess-3 code The XS-3 code is a non-weight code. This means each position with in a binary number isntassignedaffixed value. This code is a self complementing code, which

means 1s complement of the coded number yields 9s complement of the number itself. As the name indicates, XS-3 code represents a decimal number ,in binary form, as a number greater than 3. An XS-3 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 XS-3 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 XS-3 code. For Example Convert (463)10 into its XS-3 code. Given decimal number 4 6 3

Add 3 to each bit Sum

+3 +3 +3 _________________ 7 9 6

Converting the above sum into its BCD code, we have Sum BCD 7 0111 9 1001 6 0110

Hence, the XS-3 code for (463)10 is 0111 1001 0110 The following table summarizes the BCD, XS-3 codeand9scomplement representation for decimal digits. Decimal 0 1 2 3 4 5 BCD code 0000 0001 0010 0011 0100 0101 XS-3 code 0011 0100 0101 0110 0111 1000 9scomplement 1100 1011 1010 1001 1000 0111

6 7 8 9

0110 0111 1000 1001

1001 1010 1011 1100

0110 0101 0100 0011

2.9.3 Gray codes Thegraycode isntaweightedcodeand isntsuitable forarithmeticoperations,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 binary number. The second bit of the gray code equals to the sum of first and second bit of the binary 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 the binary number and so on. Example: Convert the binary (110010)2 to its gray code. Solution: 1 + 1 + 0 + 0 + 1 + 0 [Binary]

[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 binary bit. iii) Step 2 is repeated for each successive bit

For Example Convert [1010111]G to binary Solution: 1 1 0 1 1 0 0 0 1 1 1 0 1 1 Gray 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) non-weighted code c) a binary code b) the same thing as binary numbers d) an alphanumeric code

37. Which of the following 4-bit combinations is/are invalid in the BCD code? a) 1010 b) 0010 c) 0101 d) 1000

38. In XS-3 code each coded number is ________ than in BCD a) four larger b) three smaller c) three larger d) much larger

39. The XS-3 code of 01012 is a) 1001 40. Gray code is a) non-weighted code c) a binary code 41. The gray code of 01112 is a) 1000 b) 1001 c) 0101 d) 0100 b) weight code d) an alphanumeric code b) 1000 c) 1001 d) 0110

B. Answer the following questions 42. What is a BCD code? What are its advantages and disadvantages? 43. Define the XS-3 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 introducedto 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, XS-3Code, 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) c) 1101002 d) 10100011.1112

6. a)101001112

b) 1001000.011102

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) c) 011 110 111.101 0102 d) 001 101 1112

12. a) 00012 13 a ) 1110112

b) 001 111 0112

b) 0. 100 101 000 1112

c) 001 000 000.001 1002

d) 011 000 111.010 011 0012

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) 27.a) 0011 28.a) 10101 29. (a) 23. (c) 24. (d) 25. (d) c) 1.001 c) 11000.1001 32. (c) 33. (a) 26. (a)

b) 1010.01

b) 11001.0001 31. (c)

30. (b)

34.Negative numbers can be represented in sign magnitude form ,i.e. MSB represents the 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 complementform,orin2scomplementform 1scomplementcanbeeasilyobtainedusinganinverter.The2scomplementcanbe obtainedbyfirstobtainingthe1scomplementandthenadding(1)toit 35. The9scomplementofadecimalno.canbeo btained by subtracting each digit of thatdecimalno.from9.The10scomplementofadecimalno.isobtainedbyadding a1toits9scomplement. 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 4-bit 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

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 XS-3 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 XS-3 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 McGraw-Hill Publishing 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; Eastern Economy 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, Vikas Publishing House Pvt Ltd, Delhi Srinivasan, P. (2007) National Programme Technology Enhanced Learning Video Lectures on Introduction to Digital Circuits and System. Lecture I & II

Unit End Exercise

1. State the common features between different number system. 2.Whataremeantby1sand2scomplementofabinarynumber? 3.Explaintherulesforbinarysubtractionusing1sand2scomplementmethods. 4. Compare BCD and Binary systems of coding 5. How do you convert a binary number to a Gray number and vice versa.

You might also like