Difference between revisions of "Subtraction"
(→Revision) |
(→Revision) |
||
Line 27: | Line 27: | ||
subtract 00101100 from 01001011 Using Two's compliment, write your answer as an 8 bit binary number. | subtract 00101100 from 01001011 Using Two's compliment, write your answer as an 8 bit binary number. | ||
{ 00011111 } | { 00011111 } | ||
− | ||First you find the first 1 (right to left) of the binary figure you are subtracting (00101100) and invert all the ones to zeros and zeros to ones to the left of the first one giving you 11010100. Next you add your new binary number to the binary number being subtracted from (01001011), this gives you an output of 100011111. Then you disregard the ninth bit turning your nine bit answer to an eight bit answer (00011111) the correct final answer. | + | ||First you find the first 1 (right to left) of the binary figure you are subtracting (00101100) and invert all the ones to zeros and zeros to ones to the left of the first one giving you 11010100. Next you add your new binary number to the binary number being subtracted from (01001011), this gives you an output of 100011111. Then since two's compliment is eight bit you have to disregard the ninth bit turning your nine bit answer to an eight bit answer (00011111) the correct final answer. |
</quiz> | </quiz> |
Revision as of 10:34, 20 September 2017
Binary Subtraction
Binary subtraction uses twos's complement and binary addition. For example if a question asks for 73-62 in binary you would convert +62 to -62 using two's complement and then do 73+(-62) using binary addition.
First you would write out 73 and 62 in their respective binary forms using your preferred method and then add 0's to make them 8bit:
73= 64+0+0+8+0+0+1 = 1001001. In 8bit 01001001 62 =32+16+8+4+2+0 = 111110. In 8bit 00111110
Then convert +62 to -62 using your preferred method (Negative Numbers):
-62 = 11000010
Then use binary addition to add 73 and -62:
01001001 + 11000010 =100001011
However the addition left us with a carried 1 that makes the result 9bit, as two's complement uses 8bit we simply ignore the carried one making our final answer equal 00001011.
We can check by converting to denary:
00001011 = 8+2+1=11 and 73-62=11.