1's and 2's complement for 13
Answers
Answer:
1. We start with the positive version of the number:
|-13| = 13
2. Divide the number repeatedly by 2, keeping track of each remainder, until we get a quotient that is equal to zero:
division = quotient + remainder;
13 ÷ 2 = 6 + 1;
6 ÷ 2 = 3 + 0;
3 ÷ 2 = 1 + 1;
1 ÷ 2 = 0 + 1;
3. Construct the base 2 representation of the positive number, by taking all the remainders starting from the bottom of the list constructed above:
13(10) = 1101(2)
4. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 4.
A signed binary's bit length must be equal to a power of 2, as of:
21 = 2; 22 = 4; 23 = 8; 24 = 16; 25 = 32; 26 = 64; ...
First bit (the leftmost) indicates the sign,
1 = negative, 0 = positive.
The least number that is a power of 2 and is larger than the actual length so that the first bit (leftmost) could be zero is: 8.
5. Positive binary computer representation on 8 bits - if needed, add extra 0s in front (to the left) of the base 2 number, up to the required length:
13(10) = 0000 1101
6. To get the negative integer number representation on 8 bits, signed binary one's complement, replace all the bits on 0 with 1s and all the bits set on 1 with 0s (reversing the digits):
!(0000 1101) = 1111 0010
7. To get the negative integer number representation on 8 bits, signed binary two's complement, add 1 to the number calculated above:
1111 0010 + 1 = 1111 0011
Conclusion:
Number -13, a signed integer, converted from decimal system (base 10) to a signed binary two's complement representation:
-13(10) = 1111 0011
Given:
A signed integer number in the base decimal system is .
To Find:
The one's and two's complements of .
Solution:
First, we will convert the given decimal number into its binary equivalent.
For this, we divide the number repeatedly by until we get a quotient that is equal to zero. For each division, we keep noting the remainder.
, Remainder
, Remainder
, Remainder
, Remainder
Writing all the remainders starting from the bottom of the above list, we obtain the equivalent binary number as:
Now, the sign-magnitude representation of will be . Here, the sign bit is since the number is positive.
We know that the signed binary one's and two's complement form of a positive number is the same as its sign-magnitude form.
Hence,
The one's complement of is .
The two's complement of is .
Thus, the one's and two's complement of is .
#SPJ2