Respuesta :
Answer:
Using 32bits.
a:0000 0000 0000 0000 0000 0011 0100 1101
b:0000 0000 0000 0000 0011 1010 1001 1000
c:0000 0000 0000 0000 0000 0000 0110 0100
d:1111 1111 1111 1111 1111 1100 0110 0101
Explanation:
Conversion to Two's Complement
The 2's complement system is commonly used for signed integer representation on computers. The 2's complement operation is done by inverting the binary digits of an integer and then adding one.
For the purpose of explanation lets make use of a negative number for clarity. In this case lets use -923.
Note that the use of 32bits for this question is objective, you can use a range of bits for this operation. this question can go as low as 16bits and as high as 64bits depending on application and specification.
For Example:
we have -923, and want to represent it in 2's complement, you take the binary representation of positive 923:
0000 0000 0000 0000 0000 0011 1001 1011
Invert the digits.
1111 1111 1111 1111 1111 1100 0110 0100
And add one.
1111 1111 1111 1111 1111 1100 0110 0100 + 1
=
1111 1111 1111 1111 1111 1100 0110 0101
(The Binary 2's complement representation of -923)
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:
NOTES:
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).
Second Note: To convert a number to its 2's complement representation,
(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).
(ii) if the number is negative, then;
=> convert the magnitude of the number to its binary
=> add zeros to the beginning of the sequence of binary until the sequence has the specified length
=> flip each bit in the sequence and add 1 to the result.
SOLUTION:
Applying the rules in the notes above, lets convert the numbers.
(a) 845 => The number is positive, conversion to its binary will suffice
2 | 845
2 | 422 R 1
2 | 211 R 0
2 | 105 R 1
2 | 52 R 1
2 | 26 R 0
2 | 13 R 0
2 | 6 R 1
2 | 3 R 0
2 | 1 R 1
2 | 0 R 1
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