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;
- 12 345 678 911 ÷ 2 = 6 172 839 455 + 1;
- 6 172 839 455 ÷ 2 = 3 086 419 727 + 1;
- 3 086 419 727 ÷ 2 = 1 543 209 863 + 1;
- 1 543 209 863 ÷ 2 = 771 604 931 + 1;
- 771 604 931 ÷ 2 = 385 802 465 + 1;
- 385 802 465 ÷ 2 = 192 901 232 + 1;
- 192 901 232 ÷ 2 = 96 450 616 + 0;
- 96 450 616 ÷ 2 = 48 225 308 + 0;
- 48 225 308 ÷ 2 = 24 112 654 + 0;
- 24 112 654 ÷ 2 = 12 056 327 + 0;
- 12 056 327 ÷ 2 = 6 028 163 + 1;
- 6 028 163 ÷ 2 = 3 014 081 + 1;
- 3 014 081 ÷ 2 = 1 507 040 + 1;
- 1 507 040 ÷ 2 = 753 520 + 0;
- 753 520 ÷ 2 = 376 760 + 0;
- 376 760 ÷ 2 = 188 380 + 0;
- 188 380 ÷ 2 = 94 190 + 0;
- 94 190 ÷ 2 = 47 095 + 0;
- 47 095 ÷ 2 = 23 547 + 1;
- 23 547 ÷ 2 = 11 773 + 1;
- 11 773 ÷ 2 = 5 886 + 1;
- 5 886 ÷ 2 = 2 943 + 0;
- 2 943 ÷ 2 = 1 471 + 1;
- 1 471 ÷ 2 = 735 + 1;
- 735 ÷ 2 = 367 + 1;
- 367 ÷ 2 = 183 + 1;
- 183 ÷ 2 = 91 + 1;
- 91 ÷ 2 = 45 + 1;
- 45 ÷ 2 = 22 + 1;
- 22 ÷ 2 = 11 + 0;
- 11 ÷ 2 = 5 + 1;
- 5 ÷ 2 = 2 + 1;
- 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.
12 345 678 911(10) = 10 1101 1111 1101 1100 0001 1100 0011 1111(2)
3. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 34.
- 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, 34,
3) so that the first bit (leftmost) could be zero
(we deal with a positive number at this moment)
=== is: 64.
4. Get the positive binary computer representation on 64 bits (8 Bytes):
If needed, add extra 0s in front (to the left) of the base 2 number, up to the required length, 64.
Decimal Number 12 345 678 911(10) converted to signed binary in two's complement representation:
Spaces were used to group digits: for binary, by 4, for decimal, by 3.