1. Start with the positive version of the number:
|-1 152 255 341| = 1 152 255 341
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;
- 1 152 255 341 ÷ 2 = 576 127 670 + 1;
- 576 127 670 ÷ 2 = 288 063 835 + 0;
- 288 063 835 ÷ 2 = 144 031 917 + 1;
- 144 031 917 ÷ 2 = 72 015 958 + 1;
- 72 015 958 ÷ 2 = 36 007 979 + 0;
- 36 007 979 ÷ 2 = 18 003 989 + 1;
- 18 003 989 ÷ 2 = 9 001 994 + 1;
- 9 001 994 ÷ 2 = 4 500 997 + 0;
- 4 500 997 ÷ 2 = 2 250 498 + 1;
- 2 250 498 ÷ 2 = 1 125 249 + 0;
- 1 125 249 ÷ 2 = 562 624 + 1;
- 562 624 ÷ 2 = 281 312 + 0;
- 281 312 ÷ 2 = 140 656 + 0;
- 140 656 ÷ 2 = 70 328 + 0;
- 70 328 ÷ 2 = 35 164 + 0;
- 35 164 ÷ 2 = 17 582 + 0;
- 17 582 ÷ 2 = 8 791 + 0;
- 8 791 ÷ 2 = 4 395 + 1;
- 4 395 ÷ 2 = 2 197 + 1;
- 2 197 ÷ 2 = 1 098 + 1;
- 1 098 ÷ 2 = 549 + 0;
- 549 ÷ 2 = 274 + 1;
- 274 ÷ 2 = 137 + 0;
- 137 ÷ 2 = 68 + 1;
- 68 ÷ 2 = 34 + 0;
- 34 ÷ 2 = 17 + 0;
- 17 ÷ 2 = 8 + 1;
- 8 ÷ 2 = 4 + 0;
- 4 ÷ 2 = 2 + 0;
- 2 ÷ 2 = 1 + 0;
- 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.
1 152 255 341(10) = 100 0100 1010 1110 0000 0101 0110 1101(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.