Question: Write graf code for a @tm that computes the two's complement of a binary string. Show the simulation with the strings [ 0

Write \graf code for a @tm that computes the two's complement of a binary string. Show the simulation with the strings \[0100] and \[1100]. Two's complement
> The two's complement method is a modification of one's complement that fixes the problem of there being two different binary numbers representing 0. You can compute the two's complement of a binary number as @fllws:
>[1] Compute the one's complement
>[2] Add 1
//
> Below is a table showing the two's complement encodings for a 4-bit register:
//
//
:fig table
n (binary) # n (decimal) # one's complement # -n (binary) # -n (decimal)
0000 # 0 # 1111 # !{1}0000 # 0
0001 # 1 # 1110 # 1111 # -1
0010 # 2 # 1101 # 1110 # -2
0011 # 3 # 1100 # 1101 # -3
0100 # 4 # 1011 # 1100 # -4
0101 # 5 # 1010 # 1011 # -5
0110 # 6 # 1001 # 1010 # -6
0111 # 7 # 1000 # 1001 # -7
done.
//
//
[nb] The two's complement of -n produces n.
[nb] The two's complement of \[0000] overflows the register, leaving only \[0000].

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!