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;
- 189 999 999 999 ÷ 2 = 94 999 999 999 + 1;
- 94 999 999 999 ÷ 2 = 47 499 999 999 + 1;
- 47 499 999 999 ÷ 2 = 23 749 999 999 + 1;
- 23 749 999 999 ÷ 2 = 11 874 999 999 + 1;
- 11 874 999 999 ÷ 2 = 5 937 499 999 + 1;
- 5 937 499 999 ÷ 2 = 2 968 749 999 + 1;
- 2 968 749 999 ÷ 2 = 1 484 374 999 + 1;
- 1 484 374 999 ÷ 2 = 742 187 499 + 1;
- 742 187 499 ÷ 2 = 371 093 749 + 1;
- 371 093 749 ÷ 2 = 185 546 874 + 1;
- 185 546 874 ÷ 2 = 92 773 437 + 0;
- 92 773 437 ÷ 2 = 46 386 718 + 1;
- 46 386 718 ÷ 2 = 23 193 359 + 0;
- 23 193 359 ÷ 2 = 11 596 679 + 1;
- 11 596 679 ÷ 2 = 5 798 339 + 1;
- 5 798 339 ÷ 2 = 2 899 169 + 1;
- 2 899 169 ÷ 2 = 1 449 584 + 1;
- 1 449 584 ÷ 2 = 724 792 + 0;
- 724 792 ÷ 2 = 362 396 + 0;
- 362 396 ÷ 2 = 181 198 + 0;
- 181 198 ÷ 2 = 90 599 + 0;
- 90 599 ÷ 2 = 45 299 + 1;
- 45 299 ÷ 2 = 22 649 + 1;
- 22 649 ÷ 2 = 11 324 + 1;
- 11 324 ÷ 2 = 5 662 + 0;
- 5 662 ÷ 2 = 2 831 + 0;
- 2 831 ÷ 2 = 1 415 + 1;
- 1 415 ÷ 2 = 707 + 1;
- 707 ÷ 2 = 353 + 1;
- 353 ÷ 2 = 176 + 1;
- 176 ÷ 2 = 88 + 0;
- 88 ÷ 2 = 44 + 0;
- 44 ÷ 2 = 22 + 0;
- 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.
189 999 999 999(10) = 10 1100 0011 1100 1110 0001 1110 1011 1111 1111(2)
3. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 38.
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) is reserved for 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, 38,
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:
Number 189 999 999 999(10), a signed integer number (with sign),
converted from decimal system (from base 10)
and written as a signed binary (in base 2):
189 999 999 999(10) = 0000 0000 0000 0000 0000 0000 0010 1100 0011 1100 1110 0001 1110 1011 1111 1111
Spaces were used to group digits: for binary, by 4, for decimal, by 3.