1. Start with the positive version of the number:
|-2 102 132 949| = 2 102 132 949
2. Divide the number repeatedly by 2:
Keep track of each remainder.
Stop when you get a quotient that is equal to zero.
- division = quotient + remainder;
- 2 102 132 949 ÷ 2 = 1 051 066 474 + 1;
- 1 051 066 474 ÷ 2 = 525 533 237 + 0;
- 525 533 237 ÷ 2 = 262 766 618 + 1;
- 262 766 618 ÷ 2 = 131 383 309 + 0;
- 131 383 309 ÷ 2 = 65 691 654 + 1;
- 65 691 654 ÷ 2 = 32 845 827 + 0;
- 32 845 827 ÷ 2 = 16 422 913 + 1;
- 16 422 913 ÷ 2 = 8 211 456 + 1;
- 8 211 456 ÷ 2 = 4 105 728 + 0;
- 4 105 728 ÷ 2 = 2 052 864 + 0;
- 2 052 864 ÷ 2 = 1 026 432 + 0;
- 1 026 432 ÷ 2 = 513 216 + 0;
- 513 216 ÷ 2 = 256 608 + 0;
- 256 608 ÷ 2 = 128 304 + 0;
- 128 304 ÷ 2 = 64 152 + 0;
- 64 152 ÷ 2 = 32 076 + 0;
- 32 076 ÷ 2 = 16 038 + 0;
- 16 038 ÷ 2 = 8 019 + 0;
- 8 019 ÷ 2 = 4 009 + 1;
- 4 009 ÷ 2 = 2 004 + 1;
- 2 004 ÷ 2 = 1 002 + 0;
- 1 002 ÷ 2 = 501 + 0;
- 501 ÷ 2 = 250 + 1;
- 250 ÷ 2 = 125 + 0;
- 125 ÷ 2 = 62 + 1;
- 62 ÷ 2 = 31 + 0;
- 31 ÷ 2 = 15 + 1;
- 15 ÷ 2 = 7 + 1;
- 7 ÷ 2 = 3 + 1;
- 3 ÷ 2 = 1 + 1;
- 1 ÷ 2 = 0 + 1;
3. Construct the base 2 representation of the positive number:
Take all the remainders starting from the bottom of the list constructed above.
2 102 132 949(10) = 111 1101 0100 1100 0000 0000 1101 0101(2)
4. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 31.
- 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; ...
- The first bit (the leftmost) indicates the sign:
- 0 = positive integer number, 1 = negative integer number
The least number that is:
1) a power of 2
2) and is larger than the actual length, 31,
3) so that the first bit (leftmost) could be zero
(we deal with a positive number at this moment)
=== is: 32.
5. Get the positive binary computer representation on 32 bits (4 Bytes):
If needed, add extra 0s in front (to the left) of the base 2 number, up to the required length, 32.