Binary subtraction

Direct subtraction

The four possible subtractions in binary are:

  1. 0 – 0 = 0
  2. 12 – 0 = 12
  3. 12 – 12 = 0
  4. 102 – 12 = 12 ( borrow 1 from the next most significant digit to make 0 become 102,

hence 102 – 12 = 12)

Subraction using ones compliment

The main purpose of using ones compliment in computers is to perform binary subtraction. For example to get the difference in 5 – 3, using the ones compliment, we proceed as follows:

  1. Rewrite the problem as 5 + (-3) to show that he computer binary subtraction by adding the binary equivalent of 5 to ones compliment of 3.
  2. Convert the absolute value of 3 into 8-bits equivalent i.e. 000000112.
  3. Take the ones compliment of 000000112e. 111111002 which is the binary representation of -310.
  4. Add the binary equivalent of 5 to ones compliment of 3 i.e.

00000101

+ 11111000

(1)00000001

Peda.net käyttää vain välttämättömiä evästeitä istunnon ylläpitämiseen ja anonyymiin tekniseen tilastointiin. Peda.net ei koskaan käytä evästeitä markkinointiin tai kerää yksilöityjä tilastoja. Lisää tietoa evästeistä