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;
- 786 695 787 ÷ 2 = 393 347 893 + 1;
- 393 347 893 ÷ 2 = 196 673 946 + 1;
- 196 673 946 ÷ 2 = 98 336 973 + 0;
- 98 336 973 ÷ 2 = 49 168 486 + 1;
- 49 168 486 ÷ 2 = 24 584 243 + 0;
- 24 584 243 ÷ 2 = 12 292 121 + 1;
- 12 292 121 ÷ 2 = 6 146 060 + 1;
- 6 146 060 ÷ 2 = 3 073 030 + 0;
- 3 073 030 ÷ 2 = 1 536 515 + 0;
- 1 536 515 ÷ 2 = 768 257 + 1;
- 768 257 ÷ 2 = 384 128 + 1;
- 384 128 ÷ 2 = 192 064 + 0;
- 192 064 ÷ 2 = 96 032 + 0;
- 96 032 ÷ 2 = 48 016 + 0;
- 48 016 ÷ 2 = 24 008 + 0;
- 24 008 ÷ 2 = 12 004 + 0;
- 12 004 ÷ 2 = 6 002 + 0;
- 6 002 ÷ 2 = 3 001 + 0;
- 3 001 ÷ 2 = 1 500 + 1;
- 1 500 ÷ 2 = 750 + 0;
- 750 ÷ 2 = 375 + 0;
- 375 ÷ 2 = 187 + 1;
- 187 ÷ 2 = 93 + 1;
- 93 ÷ 2 = 46 + 1;
- 46 ÷ 2 = 23 + 0;
- 23 ÷ 2 = 11 + 1;
- 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.
786 695 787(10) = 10 1110 1110 0100 0000 0110 0110 1011(2)
3. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 30.
- 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, 30,
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.
Decimal Number 786 695 787(10) converted to signed binary in two's complement representation:
Spaces were used to group digits: for binary, by 4, for decimal, by 3.