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;
- 1 339 031 360 ÷ 2 = 669 515 680 + 0;
- 669 515 680 ÷ 2 = 334 757 840 + 0;
- 334 757 840 ÷ 2 = 167 378 920 + 0;
- 167 378 920 ÷ 2 = 83 689 460 + 0;
- 83 689 460 ÷ 2 = 41 844 730 + 0;
- 41 844 730 ÷ 2 = 20 922 365 + 0;
- 20 922 365 ÷ 2 = 10 461 182 + 1;
- 10 461 182 ÷ 2 = 5 230 591 + 0;
- 5 230 591 ÷ 2 = 2 615 295 + 1;
- 2 615 295 ÷ 2 = 1 307 647 + 1;
- 1 307 647 ÷ 2 = 653 823 + 1;
- 653 823 ÷ 2 = 326 911 + 1;
- 326 911 ÷ 2 = 163 455 + 1;
- 163 455 ÷ 2 = 81 727 + 1;
- 81 727 ÷ 2 = 40 863 + 1;
- 40 863 ÷ 2 = 20 431 + 1;
- 20 431 ÷ 2 = 10 215 + 1;
- 10 215 ÷ 2 = 5 107 + 1;
- 5 107 ÷ 2 = 2 553 + 1;
- 2 553 ÷ 2 = 1 276 + 1;
- 1 276 ÷ 2 = 638 + 0;
- 638 ÷ 2 = 319 + 0;
- 319 ÷ 2 = 159 + 1;
- 159 ÷ 2 = 79 + 1;
- 79 ÷ 2 = 39 + 1;
- 39 ÷ 2 = 19 + 1;
- 19 ÷ 2 = 9 + 1;
- 9 ÷ 2 = 4 + 1;
- 4 ÷ 2 = 2 + 0;
- 2 ÷ 2 = 1 + 0;
- 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.
1 339 031 360(10) = 100 1111 1100 1111 1111 1111 0100 0000(2)
3. 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.
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.
Decimal Number 1 339 031 360(10) converted to signed binary in two's complement representation:
Spaces were used to group digits: for binary, by 4, for decimal, by 3.