binary - Adding and subtracting two's complement -
using six-bit one's , two's complement representation trying solve following problem: 12 - 7 now, take 12 in binary , 7 in binary first. 12 = 001100 - 6 bit 7 = 000111 - 6 bit then, flip bit two's complement , add one? 12 = 110011 ones complement + 1 ------- 001101 7 = 111000 ones complement + 1 --------- 111001 then, add 2 complement together 001101 +111001 ------- 1000110 = overflow? discard last digit? if 5 now, if have number like -15 + 2 i add sign magnitude on msb if it's zero? like: -15 = 001111 6 bit would add 1 @ end here before flip bits? = 101111 using two's complement represent negative values has benefit subtraction , addition same. in case, can think of 12 - 7 12 + (-7) . hence need find two's complement representation of -7 , add +12: 12 001100 -7 111001 -- this, invert bits of 7 (000111) , add 1 ---------- 5 1000101 then discard carry (indicates overfl...