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;
- 172 300 465 ÷ 2 = 86 150 232 + 1;
- 86 150 232 ÷ 2 = 43 075 116 + 0;
- 43 075 116 ÷ 2 = 21 537 558 + 0;
- 21 537 558 ÷ 2 = 10 768 779 + 0;
- 10 768 779 ÷ 2 = 5 384 389 + 1;
- 5 384 389 ÷ 2 = 2 692 194 + 1;
- 2 692 194 ÷ 2 = 1 346 097 + 0;
- 1 346 097 ÷ 2 = 673 048 + 1;
- 673 048 ÷ 2 = 336 524 + 0;
- 336 524 ÷ 2 = 168 262 + 0;
- 168 262 ÷ 2 = 84 131 + 0;
- 84 131 ÷ 2 = 42 065 + 1;
- 42 065 ÷ 2 = 21 032 + 1;
- 21 032 ÷ 2 = 10 516 + 0;
- 10 516 ÷ 2 = 5 258 + 0;
- 5 258 ÷ 2 = 2 629 + 0;
- 2 629 ÷ 2 = 1 314 + 1;
- 1 314 ÷ 2 = 657 + 0;
- 657 ÷ 2 = 328 + 1;
- 328 ÷ 2 = 164 + 0;
- 164 ÷ 2 = 82 + 0;
- 82 ÷ 2 = 41 + 0;
- 41 ÷ 2 = 20 + 1;
- 20 ÷ 2 = 10 + 0;
- 10 ÷ 2 = 5 + 0;
- 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.
172 300 465(10) = 1010 0100 0101 0001 1000 1011 0001(2)
3. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 28.
- 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, 28,
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 172 300 465(10) converted to signed binary in two's complement representation:
Spaces were used to group digits: for binary, by 4, for decimal, by 3.