1. Divide the number repeatedly by 2:
Keep track of each remainder.
We stop when we get a quotient that is equal to zero.
- division = quotient + remainder;
- 842 019 129 ÷ 2 = 421 009 564 + 1;
- 421 009 564 ÷ 2 = 210 504 782 + 0;
- 210 504 782 ÷ 2 = 105 252 391 + 0;
- 105 252 391 ÷ 2 = 52 626 195 + 1;
- 52 626 195 ÷ 2 = 26 313 097 + 1;
- 26 313 097 ÷ 2 = 13 156 548 + 1;
- 13 156 548 ÷ 2 = 6 578 274 + 0;
- 6 578 274 ÷ 2 = 3 289 137 + 0;
- 3 289 137 ÷ 2 = 1 644 568 + 1;
- 1 644 568 ÷ 2 = 822 284 + 0;
- 822 284 ÷ 2 = 411 142 + 0;
- 411 142 ÷ 2 = 205 571 + 0;
- 205 571 ÷ 2 = 102 785 + 1;
- 102 785 ÷ 2 = 51 392 + 1;
- 51 392 ÷ 2 = 25 696 + 0;
- 25 696 ÷ 2 = 12 848 + 0;
- 12 848 ÷ 2 = 6 424 + 0;
- 6 424 ÷ 2 = 3 212 + 0;
- 3 212 ÷ 2 = 1 606 + 0;
- 1 606 ÷ 2 = 803 + 0;
- 803 ÷ 2 = 401 + 1;
- 401 ÷ 2 = 200 + 1;
- 200 ÷ 2 = 100 + 0;
- 100 ÷ 2 = 50 + 0;
- 50 ÷ 2 = 25 + 0;
- 25 ÷ 2 = 12 + 1;
- 12 ÷ 2 = 6 + 0;
- 6 ÷ 2 = 3 + 0;
- 3 ÷ 2 = 1 + 1;
- 1 ÷ 2 = 0 + 1;
2. Construct the base 2 representation of the positive number:
Take all the remainders starting from the bottom of the list constructed above.
842 019 129(10) = 11 0010 0011 0000 0011 0001 0011 1001(2)
3. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 30.
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, 30,
3) so that the first bit (leftmost) could be zero
(we deal with a positive number at this moment)
=== is: 32.
4. 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.
Number 842 019 129(10), a signed integer number (with sign), converted from decimal system (from base 10) and written as a signed binary in two's complement representation:
842 019 129(10) = 0011 0010 0011 0000 0011 0001 0011 1001
Spaces were used to group digits: for binary, by 4, for decimal, by 3.