60 likes | 182 Vues
This guide covers the most common method of subtracting binary numbers known as Two's Complement. The process involves two steps: complementing each digit (flipping 1s to 0s and 0s to 1s) followed by adding 1 to the result. This effectively converts the second value (the number to be subtracted) into its negative form. An example is provided to illustrate the method step by step, ensuring a comprehensive understanding of binary subtraction. Follow along to master binary arithmetic easily.
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