1. Start with the positive version of the number:
|-40 894 620| = 40 894 620
2. 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;
- 40 894 620 ÷ 2 = 20 447 310 + 0;
- 20 447 310 ÷ 2 = 10 223 655 + 0;
- 10 223 655 ÷ 2 = 5 111 827 + 1;
- 5 111 827 ÷ 2 = 2 555 913 + 1;
- 2 555 913 ÷ 2 = 1 277 956 + 1;
- 1 277 956 ÷ 2 = 638 978 + 0;
- 638 978 ÷ 2 = 319 489 + 0;
- 319 489 ÷ 2 = 159 744 + 1;
- 159 744 ÷ 2 = 79 872 + 0;
- 79 872 ÷ 2 = 39 936 + 0;
- 39 936 ÷ 2 = 19 968 + 0;
- 19 968 ÷ 2 = 9 984 + 0;
- 9 984 ÷ 2 = 4 992 + 0;
- 4 992 ÷ 2 = 2 496 + 0;
- 2 496 ÷ 2 = 1 248 + 0;
- 1 248 ÷ 2 = 624 + 0;
- 624 ÷ 2 = 312 + 0;
- 312 ÷ 2 = 156 + 0;
- 156 ÷ 2 = 78 + 0;
- 78 ÷ 2 = 39 + 0;
- 39 ÷ 2 = 19 + 1;
- 19 ÷ 2 = 9 + 1;
- 9 ÷ 2 = 4 + 1;
- 4 ÷ 2 = 2 + 0;
- 2 ÷ 2 = 1 + 0;
- 1 ÷ 2 = 0 + 1;
3. Construct the base 2 representation of the positive number:
Take all the remainders starting from the bottom of the list constructed above.
40 894 620(10) = 10 0111 0000 0000 0000 1001 1100(2)
4. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 26.
- 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, 26,
3) so that the first bit (leftmost) could be zero
(we deal with a positive number at this moment)
=== is: 32.
5. 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.