Share |

Binary Arithmetic

Here the rules for standard arithmetic for binary numbers are dicsussed

Binary Addition

Binary addition is completely straightforward and is done in the same way as standard decimal addition remembering that, in binary terms "one plus one equals zero carry one". This is also true for fractional binary numbers as illustrated below.

BinaryDecimal BinaryDecimalBinaryDecimal
10151001.19.5110.11016.8125
+110+61100.1+12.5+100.1010+4.6250
_________________________________
10111110110.022.01011.011111.4375

 

Binary Subtraction

Binary subtraction usually takes place by complementing i.e. subtraction is via the addition of negative numbers. This technique requires the use of the so-called ones (1's) complement and twos (2's) complement of a binary number.

The 1's complement of a binary number is formed simply by complmenting each digit in turn. The 2's complement of a binary number is formed by adding 1 to the least significant bit of the 1's complement (Note in the case of fractional binary numbers this is not the same as adding 1 to the 1's complement number - see below).

DecimalBinary1's Complement2's Complement
5000001011111101011111011
27000110111110010011100101
76010011001011001110110100
4.6250100.10101011.01011011.0110
Note that in order to correctly express the 1's complement and 2's complement binary numbers a fixed length format must be chosen (8-bit in the case above) and leading zeroes must be included when writing the original pure binary format number.

 

Finally, in order to represent a negative binary number the MSB becomes a sign bit i.e. if the MSB=1 then the number is negative, if the MSB=0 then the number is positive, and so, e.g. 00010011 = +19 and 10010011 = -19. This is called true magnitude format.

In order to perform binary subtraction the rules are as follows:

  • When the sum to be performed is A-B then the number to be subtracted (B) is converted to its 2's complement form and then added to A using standard binary addition.
  • If, after the addition, the sign bit = 1 then a further 2 steps must be performed :
    • first take the 2's complement of the result;
    • then make the sign bit of the new number equal to 1;
    • interpret the result in true magnitude format.
  • For sums of the form -A-B then take the 2's complement of A, add it to the 2's complement of B and then proceed as above;
  • Sums of the form -A-(-B) can be converted to B-A before proceeding as above.
Examples of binary subtraction using this method can be found in the Solved Problems.

 

Binary Multiplication and Binary Division

Binary multiplication and binary division are both most easily done by long multiplication and division methods as often taught for standard decimal numbers.

In both cases all numbers must be in true magnitude format but with sign bits removed. For multiplication each partial product is calculated and then all partial products are summed using standard binary addition. For division it proceeds like decimal division. Finally the sign of the product or quotient is determined by summing all sign bits and retaining the LSB only of the resultant sum.