Instruction
1
Binary numbers have become almost a familiar system, like decimal. Younger students learn to operate them, and to translate between systems. Binary arithmetic includes the same steps that every other: addition, subtraction, multiplication, and division.
2
Subtract in the binary number is slightly more complicated than folding, however, for this purpose there are two methods, one of which just causes the task to the operations of addition through transformation over the subtrahend. This magical transformation is the supplementary code.
3
It can be defined by the following algorithm: initially the values of all positions to be deducted, or the number of reverses: the zeros on the unit and the units on the zeros. Then the resulting intermediate result is added to the binary unit, i.e., a number that increases its LSB to 1.
4
Consider this example: you want to find the difference between 10010 – 1001. The second number is equal to 1001, for him and need to find the additional code. Change 1 to 0 and 0 to 1 → 0110. Now add to the result the number 0001. LSB equal to 0, hence its addition with the unit will give 1 → 0111.
5
Add the numbers 10010 and 0111. Perform this step sequentially for each digit starting from the right end:1+0 =1; 1+1=0 (1 "in my mind");0+1=1+1(see pred.)=0 (1 "in mind");0+0=0+1=1;1=1.
6
Record amount received: 10010+0111=11001. Follow the final stage of the method, namely, the drop unit standing in high position 11001 → 1001. This number is the difference of the given numbers.
7
Another method involves the usual digit-by-digit subtraction, similar to the above decimal numbers. If the difference is not enough units, it is in the senior category and turns into 2, so much of single digit binary numbers.
8
Do the same example in a new way:10010 – 1001:0-1= [occupy 1, the second digit remains 0] = 2-1=1;0-0=0;0-0=0;0-1=2-1=11 of high order switched in the previous step as a 2.Answer: 10010-1001 = 1001.