Answer:
(a) 845 = 0000 0011 0100 1101
(b) 1500 = 0011 1010 1001 1000
(c) 100 = 0000 0000 0110 0100
(d) -923 = 1111 1100 0110 0101
Explanation:
<u>NOTES:</u>
<em>First Note: The question requests that the numbers be represented in word-length. That means they should be represented in 16bits (a word is 2 bytes).</em>
<em>Second Note: To convert a number to its 2's complement representation,</em>
<em>(i) if the number is positive, the usual conversion to binary will suffice. You might just need to add zero at the beginning of the sequence of bits to ensure that the leftmost bit is a zero(0).</em>
<em>(ii) if the number is negative, then;</em>
<em>=> convert the magnitude of the number to its binary</em>
<em>=> add zeros to the beginning of the sequence of binary until the sequence has the specified length</em>
<em>=> flip each bit in the sequence and add 1 to the result.</em>
<u>SOLUTION:</u>
Applying the rules in the notes above, lets convert the numbers.
(a) 845 => The number is positive, conversion to its binary will suffice
<u>2 | 845</u>
<u>2 | 422 R 1</u>
<u>2 | 211 R 0</u>
<u>2 | 105 R 1</u>
<u>2 | 52 R 1</u>
<u>2 | 26 R 0</u>
<u>2 | 13 R 0</u>
<u>2 | 6 R 1</u>
<u>2 | 3 R 0</u>
<u>2 | 1 R 1</u>
<u>2 | 0 R 1</u>
Writing the remainders upwards, we have
845 = 1101001101
Pad with zeros to convert it to its word-length representation.
845 = 0000 0011 0100 1101
(b) 15000 => The number is also positive, so following the same step as above,
15000 = 11101010011000
Pad with zeros to convert it to its word-length representation.
15000 = 0011 1010 1001 1000
(c) 100 => The number is also positive, so following the same step as above,
100 = 1100100
Pad with zeros to convert it to its word-length representation.
100 = 0000 0000 0110 0100
(d) -923 => The number is negative;
--> first convert its magnitude (923) to binary
923 = 1110011011
--> Pad with zeros to convert it to its word-length representation.
923 = 0000 0011 1001 1011
--> Flip the bits
0000 0011 1001 1011 = 1111 1100 0110 0100
--> Add 1 to the result above
1111 1100 0110 0100 + 1 = 1111 1100 0110 0101
Therefore;
-923 = 1111 1100 0110 0101