1. Divide the number repeatedly by 2:
Keep track of each remainder.
Stop when you get a quotient that is equal to zero.
- division = quotient + remainder;
- 2 125 420 340 ÷ 2 = 1 062 710 170 + 0;
- 1 062 710 170 ÷ 2 = 531 355 085 + 0;
- 531 355 085 ÷ 2 = 265 677 542 + 1;
- 265 677 542 ÷ 2 = 132 838 771 + 0;
- 132 838 771 ÷ 2 = 66 419 385 + 1;
- 66 419 385 ÷ 2 = 33 209 692 + 1;
- 33 209 692 ÷ 2 = 16 604 846 + 0;
- 16 604 846 ÷ 2 = 8 302 423 + 0;
- 8 302 423 ÷ 2 = 4 151 211 + 1;
- 4 151 211 ÷ 2 = 2 075 605 + 1;
- 2 075 605 ÷ 2 = 1 037 802 + 1;
- 1 037 802 ÷ 2 = 518 901 + 0;
- 518 901 ÷ 2 = 259 450 + 1;
- 259 450 ÷ 2 = 129 725 + 0;
- 129 725 ÷ 2 = 64 862 + 1;
- 64 862 ÷ 2 = 32 431 + 0;
- 32 431 ÷ 2 = 16 215 + 1;
- 16 215 ÷ 2 = 8 107 + 1;
- 8 107 ÷ 2 = 4 053 + 1;
- 4 053 ÷ 2 = 2 026 + 1;
- 2 026 ÷ 2 = 1 013 + 0;
- 1 013 ÷ 2 = 506 + 1;
- 506 ÷ 2 = 253 + 0;
- 253 ÷ 2 = 126 + 1;
- 126 ÷ 2 = 63 + 0;
- 63 ÷ 2 = 31 + 1;
- 31 ÷ 2 = 15 + 1;
- 15 ÷ 2 = 7 + 1;
- 7 ÷ 2 = 3 + 1;
- 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.
2 125 420 340(10) = 111 1110 1010 1111 0101 0111 0011 0100(2)
3. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 31.
- 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, 31,
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 2 125 420 340(10) converted to signed binary in one's complement representation: