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 258 100 423 ÷ 2 = 629 050 211 + 1;
- 629 050 211 ÷ 2 = 314 525 105 + 1;
- 314 525 105 ÷ 2 = 157 262 552 + 1;
- 157 262 552 ÷ 2 = 78 631 276 + 0;
- 78 631 276 ÷ 2 = 39 315 638 + 0;
- 39 315 638 ÷ 2 = 19 657 819 + 0;
- 19 657 819 ÷ 2 = 9 828 909 + 1;
- 9 828 909 ÷ 2 = 4 914 454 + 1;
- 4 914 454 ÷ 2 = 2 457 227 + 0;
- 2 457 227 ÷ 2 = 1 228 613 + 1;
- 1 228 613 ÷ 2 = 614 306 + 1;
- 614 306 ÷ 2 = 307 153 + 0;
- 307 153 ÷ 2 = 153 576 + 1;
- 153 576 ÷ 2 = 76 788 + 0;
- 76 788 ÷ 2 = 38 394 + 0;
- 38 394 ÷ 2 = 19 197 + 0;
- 19 197 ÷ 2 = 9 598 + 1;
- 9 598 ÷ 2 = 4 799 + 0;
- 4 799 ÷ 2 = 2 399 + 1;
- 2 399 ÷ 2 = 1 199 + 1;
- 1 199 ÷ 2 = 599 + 1;
- 599 ÷ 2 = 299 + 1;
- 299 ÷ 2 = 149 + 1;
- 149 ÷ 2 = 74 + 1;
- 74 ÷ 2 = 37 + 0;
- 37 ÷ 2 = 18 + 1;
- 18 ÷ 2 = 9 + 0;
- 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 258 100 423(10) = 100 1010 1111 1101 0001 0110 1100 0111(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.
Number 1 258 100 423(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:
1 258 100 423(10) = 0100 1010 1111 1101 0001 0110 1100 0111
Spaces were used to group digits: for binary, by 4, for decimal, by 3.