Written by:-- Sanjay tiwari sir, My main Blog---
Continued.......Addition: - add the binary numbers 11112 and 1102 similar to the way we add the decimal numbers 1510 and 610.First, we add the numbers in the rightmost column. One plus zero adds to 1. 01111+ 001101Now we add the next column. One plus one adds to 102, so we carry the one to the next column and write the zero under this column. 101111+ 0011001Notice that the third column now contains three ones. Adding the first two ones gives us 102. Adding this sum to the remaining one gives us a total of 112, so we carry a one to the next column and write one under this column. 1101111+ 00110101The two ones in the fourth column add to 102, so we carry a one to the final column, and write zero below this column. 11101111+ 001100101Finally, the carry from the previous column plus the two zeros from this column add to 1. 11101111+ 0011010101This gives us a final answer of 101012. 11101111+ 0011010101
Algorithm:-Adding multiple binary numbers uses the same principles as adding two binary numbers, but we will approach it using a slightly different method.
First, we add the numbers in the rightmost column. Recall that 1 plus 1 adds to 102, so we can add the first pair of 1s together, and mark a carry in the next column. 10111011011010101+ 1110Now we cross out these 1s since their value is represented by the carry. The sum of the remaining digits in the first column is 1, so we write 1 below this column. 10111011011010101+ 11101The second column has two pairs of 1s, so we cross out the first pair of 1s and mark a carry in the next column to represent these values. 110111011011010101+ 11101Then we cross out the second pair of 1s and mark another carry in the next column. Now only zeros remain in this column, so we write 0 below it. 1110111011011010101+ 111001The third column has seven 1s, so we cross out three pairs of 1s, and mark three carries in the next column to represent them. An unpaired 1 remains, so we write it below this column. 1111110111011011010101+ 1110101Adding the fourth column generates two carries. Since there is no fifth column, we will create one with all zeros and mark the carries above it. Next we write the unpaired 1 below the fourth column. 1111111100111001100110100101+ 011101101Finally, adding the two carries in the last column gives us 102, so we write this below the column, and we have our answer of 1011012. 1111111100111001100110100101+ 01110101101Algorithm:-To add binary numbers with fractions, we use exactly the same technique we used to add integer binary values. The only difference is that we need to keep track of the radix point so we can distinguish the fractional part of our answer from the integer part. The example below demonstrates how to add the binary numbers 110.012 and 1.0112.First, we align the two numbers so that the radix point of each number is located in the same column. 110.01+ 1.011Next, we fill in the blank spaces with 0s and add the two numbers together. 110.010+ 001.011The first column adds to 1. 110.010+ 001.0111The second column adds to 102, so we write a 0 below it and carry a 1 to the next column. 1110.010+ 001.01101All of the remaining columns add to 1, so we write 1 below them. 1110.010+ 001.011111.101This gives us a final answer of 111.1012. 1110.010+ 001.011111.101
Addition: - subtract the binary number 101012 from 11102 using the borrow method.First, we subtract the rightmost column. 1 minus 0 equals 1. 10101- 011101In order to subtract the second column, we need to borrow a 1. So we cross out the 1 in the third column, and represent it as two 1s in the second column. 10110101- 011101We can now subtract 1 from the group of two borrowed 1s. This leaves us with 1, so we write it below the second column. 10110101- 0111011Now we subtract the next column. Since we borrowed from this column, the subtraction is 0 minus 1 and we must borrow again. However, our next column has no 1 for us to borrow. So, we must first borrow from the last column. 1 1010110101- 0111011Then borrow a 1 from the fourth column into our current column. 1111010110101- 0111011We can now perform the subtraction for the current column. We take 1 away from our group of two blue 1s. This leaves us with a single 1 which we write below the column. 1111010110101- 01110111In the fourth column, we subtract 1 from 1 for a result of 0. 1111010110101- 011100111Our last column contains contains all zeros, so we write 0 below it. This gives us our answer of 001112. 1111010110101- 0111000111
Algorithm:- multiply the binary numbers 11112 and 10112 using the same rules as decimal multiplication.First, we multiply the top number by the rightmost digit of the bottom number, just as we would in decimal. 1111x 1011Since this number is 1 and any number multiplied by 1 equals itself, we can simply record the top number below. 1111x 10111111Now we multiply the top number by the next digit in the bottom number. Since this is the second multiplication, we use a zero as a placeholder in the least significant digit of our answer. 1111x 101111110The second digit is 1 so we move the top number down into our answer. 1111x 1011111111110Next, we multiply by the third digit. Since this is the third multiplication, we record two zeros in the answer. 1111x 101111111111000Notice that the third digit is 0. Since any number multiplied by zero is zero, we place a row of zeros as our answer. 1111x 1011111111110000000Now we multiply the last digit. Since this is the fourth multiplication, we record three zeros in the answer. 1111x 1011111111110000000000The last digit is 1 so we record the top number below. 1111x 10111111111100000001111000This gives us our answer of 101001012. 1111x 1011111111110000000111100010100101
We can divide the binary number 1000012 by 1102 using the same technique as long division in the decimal system.
First, we need to find the smallest part of the dividend that is greater than the divisor 1102. Since our divisor has three digits, we begin by examining the first three digits of the dividend. 1002 is less than 1102 so we need to add another digit from our dividend.110|100001Next we try the first four digits of the dividend. Since 10002 is greater than 1102 we know we can do our division.110|1000011102 divides 10002 one time, so we write a 1 as the first digit of our quotient, copy the divisor below the dividend, and subtract using the borrow method. 1110|10000111010Now we bring down the next digit of our dividend and write it beside our remainder. Then we check to see if this new number is greater than or equal to our divisor. 1110|1000011101001002 is less than 1102 so we write a 0 in the quotient and add another digit to our reminder. 10110|100001110100110012 is greater than 1102 so we write a 1 in the quotient and subtract 1102 from 10012. 101110|100001110100111011Note that we still have a remainder after considering all the digits of the dividend. This means our answer will include a fraction. To finish our problem we need to mark the radix point and append a zero to the dividend. 101.110|100001.0110100111011Now we bring down the extra zero and compare the remainder with our divisor. Notice we ignore the radix point in our comparison. 1102 equals 1102 so we write another 1 in the quotient and subtract. This completes our division because we have no more digits in the dividend and no remainder. 101.1110|100001.011010011101101100
1’s Complement Algorith:-Representing a signed number with 1's complement is done by changing all the bits that are 1 to 0 and all the bits that are 0 to 1. Reversing the digits in this way is also called complementing a number. Let's look at an example in 4-bit arithmetic. How can we represent the number -510 in 1's complement?First, we write the positive value of the number in binary. 0101 (+5)Next, we reverse each bit of the number so 1's become 0's and 0's become 1's 1010 (-5)Here is a quick summary of how to find the 1's complement representation of any decimal number x.If x is positive, simply convert x to binary.If x is negative, write the positive value of x in binaryReverse each bit.2’s Complement Algorith:-Representing a signed number with 2's complement is done by adding 1 to the 1's complement representation of the number. To illustrate, let's look at the same example we used for 1's complement. How can we represent the number -510 in 2's complement using 4-bits?First, we write the positive value of the number in binary. 0101 (+5)Next, we reverse each bit to get the 1's complement. 1010Last, we add 1 to the number. 1011 (-5)
Here is a quick summary of how to find the 2's complement representation of any decimal number x. Notice the first three steps are the same as 1's complement.If x is positive, simply convert x to binary.If x is negative, write the positive value of x in binaryReverse each bit.Add 1 to the complemented number.Signed Number Subtraction:-Now that we can represent signed numbers with 1's and 2's complement, let's see how they will help us convert our subtraction problems to addition. Consider the problem of subtracting 110 from 710. We can also think of this problem as adding -110 to 710. In order to do this, we will use the following steps:Convert 110 to -110 with either 1's or 2's complementation.Add -110 to 710.Adjust our answer.You may be wondering why we need step three. The answer is that sometimes the sum in step two will exceed the number of bits in our representation. This is called overflow, and we handle the extra bit differently in 1's and 2's complement. In 1's complement, we add the overflow bit to our sum to obtain the final answer. In 2's complement, we simply discard the extra bit to obtain the final answer.The links below illustrate how to solve our problem using 1's complement and 2's complement arithmetic. Click on one of the links below or use the navigation bar to work through both examples in order.One's Complement | Two's ComplementOne's Complement :-Let's consider how we would solve our problem of subtracting 110 from 710 using 1's complement.First, we need to convert 00012 to its negative equivalent in 1's complement. 0111 (7)- 0001 - (1)To do this we change all the 1's to 0's and 0's to 1's. Notice that the most-significant digit is now 1 since the number is negative. 0001 -> 1110Next, we add the negative value we computed to 01112. This gives us a result of 101012. 0111 (7)+ 1110 +(-1)10101 (?)Notice that our addition caused an overflow bit. Whenever we have an overflow bit in 1's complement, we add this bit to our sum to get the correct answer. If there is no overflow bit, then we leave the sum as it is. 0101+ 10110 (6)This gives us a final answer of 01102 (or 610). 0111 (7)- 0001 - (1)0110 (6)Now let's look at an example where our problem does not generate an overflow bit. We will subtract 710 from 110 using 1's complement.First, we state our problem in binary. 0001 (1)- 0111 - (7)Next, we convert 01112 to its negative equivalent and add this to 00012. 0001 (1)+ 1000 +(-7)1001 (?)This time our results does not cause an overflow, so we do not need to adjust the sum. Notice that our final answer is a negative number since it begins with a 1. Remember that our answer is in 1's complement notation so the correct decimal value for our answer is -610 and not 910. 0001 (1)+ 1000 +(-7)1001 (-6)The animation below demonstrates how to subtract the 5-bit binary numbers 011012 and 010012 using 1's complement representationSummary:-Let's review the steps for subtracting x from y with an n-bit 1's complement representation.Negate x using 1's complement.Reverse all the bits in x to form -x.Add -x and y.If the sum exceeds n bits, add the extra bit to the result.If the sum does not exceed n bits, leave the result as it is.Two's Complement :-Now let's consider how we would solve our problem of subtracting 110 from 710 using 2's complement.First, we need to convert 00012 to its negative equivalent in 2's complement. 0111 (7)- 0001 - (1)To do this we change all the 1's to 0's and 0's to 1's and add one to the number. Notice that the most-significant digit is now 1 since the number is negative. 0001 -> 111011111Next, we add the negative value we computed to 01112. This gives us a result of 101102. 0111 (7)+ 1111 +(-1)10110 (?)Notice that our addition caused an overflow bit. Whenever we have an overflow bit in 2's complement, we discard the extra bit. This gives us a final answer of 01102 (or 610). 0111 (7)- 0001 - (1)0110 (6)
The animation below demonstrates how to subtract the 5-bit binary numbers 011012 and 010012 using 2's complement representationLet's review the steps for subtracting x from y with an n-bit 2's complement representation.Negate x using 2's complement.Reverse all the bits in x.Add 1 to form -x.Add -x and y.Discard any bits greater than n.Now go back and compare these steps with the steps for 1's complement subtraction. Notice that with 1's complement, you must check for an overflow bit each time you perform a subtraction. If the result has an overflow, you need to add the extra bit to your result to obtain the correct answer. However, with 2's complement, we only need to ignore this extra bit. No other computations are required to find the correct answer. This makes 2's complement a more efficient way of representing signed numbers and performing binary subtraction
My main Blog--- click to watch my full Blog------- (http://www.Buyonlineprojects.blogspot.com)