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 253 275 ÷ 2 = 393 126 637 + 1;
- 393 126 637 ÷ 2 = 196 563 318 + 1;
- 196 563 318 ÷ 2 = 98 281 659 + 0;
- 98 281 659 ÷ 2 = 49 140 829 + 1;
- 49 140 829 ÷ 2 = 24 570 414 + 1;
- 24 570 414 ÷ 2 = 12 285 207 + 0;
- 12 285 207 ÷ 2 = 6 142 603 + 1;
- 6 142 603 ÷ 2 = 3 071 301 + 1;
- 3 071 301 ÷ 2 = 1 535 650 + 1;
- 1 535 650 ÷ 2 = 767 825 + 0;
- 767 825 ÷ 2 = 383 912 + 1;
- 383 912 ÷ 2 = 191 956 + 0;
- 191 956 ÷ 2 = 95 978 + 0;
- 95 978 ÷ 2 = 47 989 + 0;
- 47 989 ÷ 2 = 23 994 + 1;
- 23 994 ÷ 2 = 11 997 + 0;
- 11 997 ÷ 2 = 5 998 + 1;
- 5 998 ÷ 2 = 2 999 + 0;
- 2 999 ÷ 2 = 1 499 + 1;
- 1 499 ÷ 2 = 749 + 1;
- 749 ÷ 2 = 374 + 1;
- 374 ÷ 2 = 187 + 0;
- 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 253 275(10) = 10 1110 1101 1101 0100 0101 1101 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) 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, 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:
Number 786 253 275(10), a signed integer number (with sign),
converted from decimal system (from base 10)
and written as a signed binary (in base 2):
786 253 275(10) = 0010 1110 1101 1101 0100 0101 1101 1011
Spaces were used to group digits: for binary, by 4, for decimal, by 3.