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;
- 419 748 402 ÷ 2 = 209 874 201 + 0;
- 209 874 201 ÷ 2 = 104 937 100 + 1;
- 104 937 100 ÷ 2 = 52 468 550 + 0;
- 52 468 550 ÷ 2 = 26 234 275 + 0;
- 26 234 275 ÷ 2 = 13 117 137 + 1;
- 13 117 137 ÷ 2 = 6 558 568 + 1;
- 6 558 568 ÷ 2 = 3 279 284 + 0;
- 3 279 284 ÷ 2 = 1 639 642 + 0;
- 1 639 642 ÷ 2 = 819 821 + 0;
- 819 821 ÷ 2 = 409 910 + 1;
- 409 910 ÷ 2 = 204 955 + 0;
- 204 955 ÷ 2 = 102 477 + 1;
- 102 477 ÷ 2 = 51 238 + 1;
- 51 238 ÷ 2 = 25 619 + 0;
- 25 619 ÷ 2 = 12 809 + 1;
- 12 809 ÷ 2 = 6 404 + 1;
- 6 404 ÷ 2 = 3 202 + 0;
- 3 202 ÷ 2 = 1 601 + 0;
- 1 601 ÷ 2 = 800 + 1;
- 800 ÷ 2 = 400 + 0;
- 400 ÷ 2 = 200 + 0;
- 200 ÷ 2 = 100 + 0;
- 100 ÷ 2 = 50 + 0;
- 50 ÷ 2 = 25 + 0;
- 25 ÷ 2 = 12 + 1;
- 12 ÷ 2 = 6 + 0;
- 6 ÷ 2 = 3 + 0;
- 3 ÷ 2 = 1 + 1;
- 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.
419 748 402(10) = 1 1001 0000 0100 1101 1010 0011 0010(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 419 748 402(10), a signed integer number (with sign),
converted from decimal system (from base 10)
and written as a signed binary (in base 2):
419 748 402(10) = 0001 1001 0000 0100 1101 1010 0011 0010
Spaces were used to group digits: for binary, by 4, for decimal, by 3.