60 likes | 170 Views
Subtracting Binary. Subtracting Binary. The most common way of subtracting binary numbers is done by first taking the second value (the number to be subtracted) and apply what is known as two's complement , this is done in two steps: Complement each digit in turn (change 1 to 0 and 0 to 1)
E N D
Subtracting Binary • The most common way of subtracting binary numbers is done by first taking the second value (the number to be subtracted) and apply what is known as two's complement, this is done in two steps: • Complement each digit in turn (change 1 to 0 and 0 to 1) • Add 1 (one) to the result • We are in fact turning the second value (the number to be subtracted) into a negative • Example: 5 -2 = 3 is the same as 5 + (-2) = 3
Example:11012 - 01002 First we complement each digit of the second value (change 1 to 0 and 0 to 1) We start with 0100 and complement each value. 0 0 0 1 1 1 0 1 1 1 + 1 We then add 1 to the result 1 1 0 0 2
Now we add 1101 to our new number 1100. 1 1 1 1 0 1 + 1 1 0 0 X 1 1 0 0 1 9 = 2 10 When we do this addition, we always disregard the last carry.
Final Check 11012 – 01002 = 10012 In decimal format: 1310 – 410 = 910