Difference between revisions of "Subtraction"
(→Revision) |
Jmiester26 (talk | contribs) (→Revision) |
||
Line 35: | Line 35: | ||
{ 00111010 } | { 00111010 } | ||
||First you convert 107 and 49 to binary giving 01101011 and 00110001 respectively. then you convert 00110001 to a negative by inverting all figures after the first one right to left giving 11001111. then you add the two binary figures 01101011 and 11001111 giving 100111010, this answer is nine bit so you disregard the first bit making it the eight bit number 00111010, the correct answer. | ||First you convert 107 and 49 to binary giving 01101011 and 00110001 respectively. then you convert 00110001 to a negative by inverting all figures after the first one right to left giving 11001111. then you add the two binary figures 01101011 and 11001111 giving 100111010, this answer is nine bit so you disregard the first bit making it the eight bit number 00111010, the correct answer. | ||
+ | |||
+ | |||
+ | { | ||
+ | |type="{}"} | ||
+ | Using Two's compliment work out 52 - 87, give your answer as a two's compliment binary integer. | ||
+ | { 11100111 } | ||
+ | ||First you convert 52 and 87 to binary giving 00110100 and 01001101 respectively. Then you convert 87 (01001101) to a negative by inverting all figures after the first 1 on the right giving 10110011. then you add the two binary figures 00110100 and 10110011 giving 11100111, this answer is nine bit so you disregard the first bit making it the eight bit number 00111010, the correct answer. | ||
+ | |||
+ | |||
</quiz> | </quiz> |
Revision as of 12:23, 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.