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;
- 299 799 889 ÷ 2 = 149 899 944 + 1;
- 149 899 944 ÷ 2 = 74 949 972 + 0;
- 74 949 972 ÷ 2 = 37 474 986 + 0;
- 37 474 986 ÷ 2 = 18 737 493 + 0;
- 18 737 493 ÷ 2 = 9 368 746 + 1;
- 9 368 746 ÷ 2 = 4 684 373 + 0;
- 4 684 373 ÷ 2 = 2 342 186 + 1;
- 2 342 186 ÷ 2 = 1 171 093 + 0;
- 1 171 093 ÷ 2 = 585 546 + 1;
- 585 546 ÷ 2 = 292 773 + 0;
- 292 773 ÷ 2 = 146 386 + 1;
- 146 386 ÷ 2 = 73 193 + 0;
- 73 193 ÷ 2 = 36 596 + 1;
- 36 596 ÷ 2 = 18 298 + 0;
- 18 298 ÷ 2 = 9 149 + 0;
- 9 149 ÷ 2 = 4 574 + 1;
- 4 574 ÷ 2 = 2 287 + 0;
- 2 287 ÷ 2 = 1 143 + 1;
- 1 143 ÷ 2 = 571 + 1;
- 571 ÷ 2 = 285 + 1;
- 285 ÷ 2 = 142 + 1;
- 142 ÷ 2 = 71 + 0;
- 71 ÷ 2 = 35 + 1;
- 35 ÷ 2 = 17 + 1;
- 17 ÷ 2 = 8 + 1;
- 8 ÷ 2 = 4 + 0;
- 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.
299 799 889(10) = 1 0001 1101 1110 1001 0101 0101 0001(2)
3. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 29.
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, 29,
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 299 799 889(10), a signed integer number (with sign),
converted from decimal system (from base 10)
and written as a signed binary (in base 2):
299 799 889(10) = 0001 0001 1101 1110 1001 0101 0101 0001
Spaces were used to group digits: for binary, by 4, for decimal, by 3.