In: Computer Science
Perform the following arithmetic in Binary assuming 16 bit registers
(67)10 + (-89)10
List the values of the status bits: C, V, N and Z

C = 0 (No carry)
V = 0 (No overflow)
N = 1 (Negative)
Z = 0 (Not zero)
Explanation:
-------------
Number: 67
Let's convert this to two's complement binary
67
Since this is a positive number. we can directly convert this into binary
Divide 67 successively by 2 until the quotient is 0
> 67/2 = 33, remainder is 1
> 33/2 = 16, remainder is 1
> 16/2 = 8, remainder is 0
> 8/2 = 4, remainder is 0
> 4/2 = 2, remainder is 0
> 2/2 = 1, remainder is 0
> 1/2 = 0, remainder is 1
Read remainders from the bottom to top as 1000011
So, 67 of decimal is 1000011 in binary
so, 67 in 2's complement binary is 0000000001000011
Number: -89
Let's convert this to two's complement binary
-89
This is negative. so, follow these steps to convert this into a 2's complement binary
Step 1:
Divide 89 successively by 2 until the quotient is 0
> 89/2 = 44, remainder is 1
> 44/2 = 22, remainder is 0
> 22/2 = 11, remainder is 0
> 11/2 = 5, remainder is 1
> 5/2 = 2, remainder is 1
> 2/2 = 1, remainder is 0
> 1/2 = 0, remainder is 1
Read remainders from the bottom to top as 1011001
So, 89 of decimal is 1011001 in binary
So, 89 in normal binary is 0000000001011001
Step 2: flip all the bits. Flip all 0's to 1 and all 1's to 0.
0000000001011001 is flipped to 1111111110100110
Step 3:. Add 1 to above result
1111111110100110 + 1 = 1111111110100111
so, -89 in 2's complement binary is 1111111110100111
Adding 0000000001000011 and 1111111110100111 in binary
0000000001000011
1111111110100111
---------------------
(0)1111111111101010
---------------------
Sum does not produces a carry
So, sum of these numbers in binary is 1111111111101010
Verification:
---------------
sum = 1111111111101010
since left most bit is 1, this number is negative number.
so, follow these steps below to convert this into a decimal value.
I. first flip all the bits. Flip all 0's to 1 and all 1's to 0.
1111111111101010 is flipped to 0000000000010101
II. Add 1 to above result
0000000000010101 + 1 = 0000000000010110
III. Now convert this result to decimal value
Converting 10110 to decimal
10110
=> 1x2^4+0x2^3+1x2^2+1x2^1+0x2^0
=> 1x16+0x8+1x4+1x2+0x1
=> 16+0+4+2+0
=> 22
Answer: -22
This is correct since we can verify that 67+-89 = -22
So, there was no overflow.