What are the required steps to convert base 10 integer
number 111 000 011 109 858 to signed binary code (in base 2)?
- A signed integer, written in base ten, or a decimal system number, is a number written using the digits 0 through 9 and the sign, which can be positive (+) or negative (-). If positive, the sign is usually not written. A number written in base two, or binary, is a number written using only the digits 0 and 1.
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;
- 111 000 011 109 858 ÷ 2 = 55 500 005 554 929 + 0;
- 55 500 005 554 929 ÷ 2 = 27 750 002 777 464 + 1;
- 27 750 002 777 464 ÷ 2 = 13 875 001 388 732 + 0;
- 13 875 001 388 732 ÷ 2 = 6 937 500 694 366 + 0;
- 6 937 500 694 366 ÷ 2 = 3 468 750 347 183 + 0;
- 3 468 750 347 183 ÷ 2 = 1 734 375 173 591 + 1;
- 1 734 375 173 591 ÷ 2 = 867 187 586 795 + 1;
- 867 187 586 795 ÷ 2 = 433 593 793 397 + 1;
- 433 593 793 397 ÷ 2 = 216 796 896 698 + 1;
- 216 796 896 698 ÷ 2 = 108 398 448 349 + 0;
- 108 398 448 349 ÷ 2 = 54 199 224 174 + 1;
- 54 199 224 174 ÷ 2 = 27 099 612 087 + 0;
- 27 099 612 087 ÷ 2 = 13 549 806 043 + 1;
- 13 549 806 043 ÷ 2 = 6 774 903 021 + 1;
- 6 774 903 021 ÷ 2 = 3 387 451 510 + 1;
- 3 387 451 510 ÷ 2 = 1 693 725 755 + 0;
- 1 693 725 755 ÷ 2 = 846 862 877 + 1;
- 846 862 877 ÷ 2 = 423 431 438 + 1;
- 423 431 438 ÷ 2 = 211 715 719 + 0;
- 211 715 719 ÷ 2 = 105 857 859 + 1;
- 105 857 859 ÷ 2 = 52 928 929 + 1;
- 52 928 929 ÷ 2 = 26 464 464 + 1;
- 26 464 464 ÷ 2 = 13 232 232 + 0;
- 13 232 232 ÷ 2 = 6 616 116 + 0;
- 6 616 116 ÷ 2 = 3 308 058 + 0;
- 3 308 058 ÷ 2 = 1 654 029 + 0;
- 1 654 029 ÷ 2 = 827 014 + 1;
- 827 014 ÷ 2 = 413 507 + 0;
- 413 507 ÷ 2 = 206 753 + 1;
- 206 753 ÷ 2 = 103 376 + 1;
- 103 376 ÷ 2 = 51 688 + 0;
- 51 688 ÷ 2 = 25 844 + 0;
- 25 844 ÷ 2 = 12 922 + 0;
- 12 922 ÷ 2 = 6 461 + 0;
- 6 461 ÷ 2 = 3 230 + 1;
- 3 230 ÷ 2 = 1 615 + 0;
- 1 615 ÷ 2 = 807 + 1;
- 807 ÷ 2 = 403 + 1;
- 403 ÷ 2 = 201 + 1;
- 201 ÷ 2 = 100 + 1;
- 100 ÷ 2 = 50 + 0;
- 50 ÷ 2 = 25 + 0;
- 25 ÷ 2 = 12 + 1;
- 12 ÷ 2 = 6 + 0;
- 6 ÷ 2 = 3 + 0;
- 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.
111 000 011 109 858(10) = 110 0100 1111 0100 0011 0100 0011 1011 0111 0101 1110 0010(2)
3. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 47.
- 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, 47,
3) so that the first bit (leftmost) could be zero
(we deal with a positive number at this moment)
=== is: 64.
4. Get the positive binary computer representation on 64 bits (8 Bytes):
If needed, add extra 0s in front (to the left) of the base 2 number, up to the required length, 64:
111 000 011 109 858(10) Base 10 integer number converted and written as a signed binary code (in base 2):
111 000 011 109 858(10) = 0000 0000 0000 0000 0110 0100 1111 0100 0011 0100 0011 1011 0111 0101 1110 0010
Spaces were used to group digits: for binary, by 4, for decimal, by 3.