 Hello dear learners, I am Dr. Stratistrova Purali, Assistant Professor in the Department of Computer Science working at Krishna Kanto-Hendikoi State Open University. In this video, I am going to talk about coding techniques. This topic is a part of the course Digital Techniques. Coding of characters has been standardized to enable transfer of data between computers. We need to represent different kinds of data like symbols, numeric, alpha-numeric data in the computer system. Computers use binary coding schemes to represent this data internally. Some of the popular coding schemes are BCD, ASCII and GrapeCode. Now, let us look at the first coding scheme that is binary coded decimal or BCD. BCD is a way to express each of the decimal digits with the binary equivalent. It is a four digit binary code for representing 0 to 9 in the decimal form. Now, if you look at the slide in the right hand side, you can see that we have the decimal numbers 0, 1, 2, 3 and then we have their corresponding BCD form. Now, this BCD form is the binary equivalent of the decimal numbers. Now, let us look at how we can convert a number from decimal to BCD. So, now if we want to convert the decimal number 13 to its BCD form, then we can proceed in this way. So, first of all, we will convert the first digit that is 1 in this case. So, we will take the BCD equivalent of 1. So, which is 0, 0, 0, 1 which is simply the binary equivalent of 1 in, but now we are going to use four bits to represent this. Next, we will take the second digit that is 3 and now again we will convert 3 into its BCD form that is 0, 0, 1, 1. So, to get the decimal equivalent of 1, 3 what we will do is we will combine this 1 and 3 and then we will get the BCD equivalent of 13. So, that will be 0, 0, 0, 1, 0, 0, 1, 1. So, in this way we can convert any decimal number to its BCD form. So, now let us look at an example where we can convert a BCD number to its decimal equivalent. So, for that in this example we have taken a BCD number 1, 0, 0, 0, 0, 1, 1. So, we are going to convert this BCD number to its decimal equivalent. So, for that what we have to do is we need to look at this BCD numbers as a four bit number and we will start there by going from left to right. So, the first four numbers I am going to combine this and then I need to get the decimal equivalent of this four bit. So, the decimal equivalent of 1, 0, 0, 0 will be 8. Now again the decimal equivalent of this four bits that is 0, 0, 1, 1 will be 3. So, in this way I can get the decimal equivalent of a BCD number. So, I simply need to combine these two digits that is 8 and 3 and I get the decimal equivalent of a BCD number. Now, learners let us look at the rules for doing BCD addition. So, the first rule is that we can add two BCD numbers using the binary addition rules itself. And the second is that if the four bits sum is equal to or less than 9 then it is a valid BCD number. But if a four bit sum is greater than 9 or if there is a carry of a four bit group generated then it will be an invalid result. There are six invalid states for BCD addition. These are 1, 0, 1, 0 that is 10, 1, 0, 1, 1, 11, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0 and 1, 1, 1, 1, 1. So, these six states are six these are the invalid states. So, now if we get the states what we need to do is we need to add 6 that is 0, 1, 1, 0 to the four bit sum in order to skip these six states and then return the code again to the BCD form. Now, if there is a carry again then the results are again then we need to add 6 again to it and we simply add the carry to the next four bit group. So, now let us look at an example on how we can do BCD addition. So, learners now let us look at the addition for two BCD numbers. So, we have taken two numbers the first one is this and the second one is this. So, now for adding them again we need to divide them into four bit numbers. So, again this one also we will take it as four bit. So, now and then we will add the first part of this four bit number to the first part of the second number and the second part of this first four bit number to the second part of the second four bit number. So, here we can see this 1, 0, 0, 1 we are adding it with this one 0, 0, 0, 1. So, now we get a result then this is simple binary addition. So, we can see the result will be 1, 0, 1, 0. Now, this 1, 0, 1, 0 is an invalid BCD form. So, what we need to do is we need to add 6 that is 0, 1, 1, 0 to this number group. Now, before doing this addition let us look at the second part of the voter numbers. So, now what we will do is we have this part that is 0, 1, 1, 1 we are going to add this with the second one that is 0, 0, 1, 0. So, now we will have the addition and get the result as 1, 0, 0, 1 which is a valid BCD form. So, now if you look at the decimal numbers of this BCD form then the first number is equivalent to 97 and the second number is equivalent to 12. So, now our this part is valid. So, we do not need to add any 6 component to here, but since this part is invalid we need to add 6 that is represented by 0, 1, 1, 0 to this invalid BCD number. So, for doing that we have this addition and now if we see this is again simple binary addition. So, if we see now we will get 0 plus 0, 0, 1 plus 1, 0 and have a carry of 1 again 1 plus 1, 0 and again a carry of 1. So, 1 plus 1, 0 and a carry of 1. So, now this carry over 1 will come here we are going to add this carry in the front of this BCD number. So, now the equivalent of the equivalent addition of this two BCD numbers will be 1, 0, 0, 1, 0, 0, 0 and 1, 0, 0, 1 this one. So, all of this part together will be the addition value of this two BCD numbers. Now, in the decimal form also if we see 97 plus 12 should give us a value of 109 which we get from when we convert this BCD number to its decimal form. Now, learners let us look at the second coding technique that is American Standard Code for Information Interchange or ASCII. Now, the ASCII is a 7 bit binary code and so it represents 128 character codes. Now, these character codes are starting from 0 to 127. Now, let us look at an example the code for the capital letter A is always represented by the order number 65 which can be easily represented using 0s and 1s in binary. And the first 32 characters in the ASCII table are unprintable control codes. For example, NAL, ESCII, these are some kind of examples of the control CAD codes in ASCII format. Now, let us look at another coding technique. Another popular coding technique is extended binary coded decimal interchange code or EBCDIC. Now, EBCDIC is an IBM code for representing characters as numbers. Now, it uses 8 bits per character and thus it can represent 256 characters. In this format, the first 4 bits are known as zone bits and the remaining 4 bits they represent the digit values. Now, let us look at another coding technique. The next coding technique is gray code. Now, the gray code is named after Frank K where it is a binary numeral system where two successive values differ in only one digit. Now, if you see at the right-hand side of the slide we can see that we have the decimal equivalence and then we have the gray code equivalence and also we have the binary equivalence. So, now if you look at the first gray code for representing decimal number 0 it is 0001. Now, if you look at the second decimal number 1 its equivalent gray code is 0001. So, now for each successive gray code only one bit position is going to change. Now, this happens for all the gray codes. Now, gray code is used to facilitate error correction in digital communication systems. Now, let us look at the rules for binary to gray code conversion. So, there are two steps in it. The first step is that the most significant bit that is the left-most bit in the gray code will be the same as the corresponding most significant bit in the binary code. The step 2 is that we will go from left to right and then add each pair of adjacent bits of binary code to get the next gray bit code. And if there is a carry in this addition then we are going to discard that carry. Now, let us look at an example for binary to gray code conversion. So, learners now let us try to find a gray code for this binary code that is 01011. So, we have already stated in the rules that the MSP part will be same. So, the MSP for this binary is 1 so that MSP for the gray code will also be 1. So, in the next step what we are going to do is we are going to add this we are going to start from left to right. So, what we are going to do is we are going to add this 1 with this 0 in the binary code. So, 1 plus 0 we have 1 so that will be the equivalent next gray code position. Again 0 plus 1 again we get a value of 1 so this will be placed in the next position. Again we have 1 plus 1 so we will have 1 plus 1 is 1 0 we will discard the carry that is 1 and the 0 will keep. So, the gray code equivalent of the binary code 1011 will be 1110. Now, learners in the previous slide we have seen how to convert from binary code to gray code. Now, in this slide we are going to see how we can convert from gray code to binary code. So, the first step is the same that is the most significant bit or the left most bit in the binary code will be the same as the corresponding most significant bit in the gray code. In the second step now we are going to add each binary code bit generated by the gray code to the next addition position of the gray code. And if there is a carry in this addition then we are going to discard the carry part. Now, let us look at an example. Now, learners in this example we are going to find out the gray code equivalent of a binary code that is 1110. So, here we have this binary number 1110 and now if you want to find out the gray code we already know that the msv value of the binary code will be same with the gray code. So, this one will be convert as soon as it is. Now, we are going the next rules but we have as we are going to add this newly generated gray code bit with the adjacent binary code bit. So, we are going to add 1 plus 1. So, we get a value of 10. So, one part we are going to discard it and the 0 will keep it here. Now, again this is the newly generated gray code bit. So, this newly generated code bit we are going to add with the adjacent binary. So, this is the adjacent binary. So, we are going to add 0 plus 1. So, we get the addition value 1. Again this is the newly generated code. So, we are going to add this 1 with the adjacent binary code that is 0. So, we will get 1 plus 0 we will get 1. So, now the gray code equivalent of the binary code 1110 will be 1011. Thank you for listening to this video.