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;
- 381 497 425 ÷ 2 = 190 748 712 + 1;
- 190 748 712 ÷ 2 = 95 374 356 + 0;
- 95 374 356 ÷ 2 = 47 687 178 + 0;
- 47 687 178 ÷ 2 = 23 843 589 + 0;
- 23 843 589 ÷ 2 = 11 921 794 + 1;
- 11 921 794 ÷ 2 = 5 960 897 + 0;
- 5 960 897 ÷ 2 = 2 980 448 + 1;
- 2 980 448 ÷ 2 = 1 490 224 + 0;
- 1 490 224 ÷ 2 = 745 112 + 0;
- 745 112 ÷ 2 = 372 556 + 0;
- 372 556 ÷ 2 = 186 278 + 0;
- 186 278 ÷ 2 = 93 139 + 0;
- 93 139 ÷ 2 = 46 569 + 1;
- 46 569 ÷ 2 = 23 284 + 1;
- 23 284 ÷ 2 = 11 642 + 0;
- 11 642 ÷ 2 = 5 821 + 0;
- 5 821 ÷ 2 = 2 910 + 1;
- 2 910 ÷ 2 = 1 455 + 0;
- 1 455 ÷ 2 = 727 + 1;
- 727 ÷ 2 = 363 + 1;
- 363 ÷ 2 = 181 + 1;
- 181 ÷ 2 = 90 + 1;
- 90 ÷ 2 = 45 + 0;
- 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.
381 497 425(10) = 1 0110 1011 1101 0011 0000 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) 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, 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 381 497 425(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:
381 497 425(10) = 0001 0110 1011 1101 0011 0000 0101 0001
Spaces were used to group digits: for binary, by 4, for decimal, by 3.