What are the required steps to convert base 10 integer
number 3 000 233 739 869 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;
- 3 000 233 739 869 ÷ 2 = 1 500 116 869 934 + 1;
- 1 500 116 869 934 ÷ 2 = 750 058 434 967 + 0;
- 750 058 434 967 ÷ 2 = 375 029 217 483 + 1;
- 375 029 217 483 ÷ 2 = 187 514 608 741 + 1;
- 187 514 608 741 ÷ 2 = 93 757 304 370 + 1;
- 93 757 304 370 ÷ 2 = 46 878 652 185 + 0;
- 46 878 652 185 ÷ 2 = 23 439 326 092 + 1;
- 23 439 326 092 ÷ 2 = 11 719 663 046 + 0;
- 11 719 663 046 ÷ 2 = 5 859 831 523 + 0;
- 5 859 831 523 ÷ 2 = 2 929 915 761 + 1;
- 2 929 915 761 ÷ 2 = 1 464 957 880 + 1;
- 1 464 957 880 ÷ 2 = 732 478 940 + 0;
- 732 478 940 ÷ 2 = 366 239 470 + 0;
- 366 239 470 ÷ 2 = 183 119 735 + 0;
- 183 119 735 ÷ 2 = 91 559 867 + 1;
- 91 559 867 ÷ 2 = 45 779 933 + 1;
- 45 779 933 ÷ 2 = 22 889 966 + 1;
- 22 889 966 ÷ 2 = 11 444 983 + 0;
- 11 444 983 ÷ 2 = 5 722 491 + 1;
- 5 722 491 ÷ 2 = 2 861 245 + 1;
- 2 861 245 ÷ 2 = 1 430 622 + 1;
- 1 430 622 ÷ 2 = 715 311 + 0;
- 715 311 ÷ 2 = 357 655 + 1;
- 357 655 ÷ 2 = 178 827 + 1;
- 178 827 ÷ 2 = 89 413 + 1;
- 89 413 ÷ 2 = 44 706 + 1;
- 44 706 ÷ 2 = 22 353 + 0;
- 22 353 ÷ 2 = 11 176 + 1;
- 11 176 ÷ 2 = 5 588 + 0;
- 5 588 ÷ 2 = 2 794 + 0;
- 2 794 ÷ 2 = 1 397 + 0;
- 1 397 ÷ 2 = 698 + 1;
- 698 ÷ 2 = 349 + 0;
- 349 ÷ 2 = 174 + 1;
- 174 ÷ 2 = 87 + 0;
- 87 ÷ 2 = 43 + 1;
- 43 ÷ 2 = 21 + 1;
- 21 ÷ 2 = 10 + 1;
- 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.
3 000 233 739 869(10) = 10 1011 1010 1000 1011 1101 1101 1100 0110 0101 1101(2)
3. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 42.
- 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, 42,
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:
3 000 233 739 869(10) Base 10 integer number converted and written as a signed binary code (in base 2):
3 000 233 739 869(10) = 0000 0000 0000 0000 0000 0010 1011 1010 1000 1011 1101 1101 1100 0110 0101 1101
Spaces were used to group digits: for binary, by 4, for decimal, by 3.