What are the required steps to convert base 10 integer
number 1 109 999 999 999 999 516 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;
- 1 109 999 999 999 999 516 ÷ 2 = 554 999 999 999 999 758 + 0;
- 554 999 999 999 999 758 ÷ 2 = 277 499 999 999 999 879 + 0;
- 277 499 999 999 999 879 ÷ 2 = 138 749 999 999 999 939 + 1;
- 138 749 999 999 999 939 ÷ 2 = 69 374 999 999 999 969 + 1;
- 69 374 999 999 999 969 ÷ 2 = 34 687 499 999 999 984 + 1;
- 34 687 499 999 999 984 ÷ 2 = 17 343 749 999 999 992 + 0;
- 17 343 749 999 999 992 ÷ 2 = 8 671 874 999 999 996 + 0;
- 8 671 874 999 999 996 ÷ 2 = 4 335 937 499 999 998 + 0;
- 4 335 937 499 999 998 ÷ 2 = 2 167 968 749 999 999 + 0;
- 2 167 968 749 999 999 ÷ 2 = 1 083 984 374 999 999 + 1;
- 1 083 984 374 999 999 ÷ 2 = 541 992 187 499 999 + 1;
- 541 992 187 499 999 ÷ 2 = 270 996 093 749 999 + 1;
- 270 996 093 749 999 ÷ 2 = 135 498 046 874 999 + 1;
- 135 498 046 874 999 ÷ 2 = 67 749 023 437 499 + 1;
- 67 749 023 437 499 ÷ 2 = 33 874 511 718 749 + 1;
- 33 874 511 718 749 ÷ 2 = 16 937 255 859 374 + 1;
- 16 937 255 859 374 ÷ 2 = 8 468 627 929 687 + 0;
- 8 468 627 929 687 ÷ 2 = 4 234 313 964 843 + 1;
- 4 234 313 964 843 ÷ 2 = 2 117 156 982 421 + 1;
- 2 117 156 982 421 ÷ 2 = 1 058 578 491 210 + 1;
- 1 058 578 491 210 ÷ 2 = 529 289 245 605 + 0;
- 529 289 245 605 ÷ 2 = 264 644 622 802 + 1;
- 264 644 622 802 ÷ 2 = 132 322 311 401 + 0;
- 132 322 311 401 ÷ 2 = 66 161 155 700 + 1;
- 66 161 155 700 ÷ 2 = 33 080 577 850 + 0;
- 33 080 577 850 ÷ 2 = 16 540 288 925 + 0;
- 16 540 288 925 ÷ 2 = 8 270 144 462 + 1;
- 8 270 144 462 ÷ 2 = 4 135 072 231 + 0;
- 4 135 072 231 ÷ 2 = 2 067 536 115 + 1;
- 2 067 536 115 ÷ 2 = 1 033 768 057 + 1;
- 1 033 768 057 ÷ 2 = 516 884 028 + 1;
- 516 884 028 ÷ 2 = 258 442 014 + 0;
- 258 442 014 ÷ 2 = 129 221 007 + 0;
- 129 221 007 ÷ 2 = 64 610 503 + 1;
- 64 610 503 ÷ 2 = 32 305 251 + 1;
- 32 305 251 ÷ 2 = 16 152 625 + 1;
- 16 152 625 ÷ 2 = 8 076 312 + 1;
- 8 076 312 ÷ 2 = 4 038 156 + 0;
- 4 038 156 ÷ 2 = 2 019 078 + 0;
- 2 019 078 ÷ 2 = 1 009 539 + 0;
- 1 009 539 ÷ 2 = 504 769 + 1;
- 504 769 ÷ 2 = 252 384 + 1;
- 252 384 ÷ 2 = 126 192 + 0;
- 126 192 ÷ 2 = 63 096 + 0;
- 63 096 ÷ 2 = 31 548 + 0;
- 31 548 ÷ 2 = 15 774 + 0;
- 15 774 ÷ 2 = 7 887 + 0;
- 7 887 ÷ 2 = 3 943 + 1;
- 3 943 ÷ 2 = 1 971 + 1;
- 1 971 ÷ 2 = 985 + 1;
- 985 ÷ 2 = 492 + 1;
- 492 ÷ 2 = 246 + 0;
- 246 ÷ 2 = 123 + 0;
- 123 ÷ 2 = 61 + 1;
- 61 ÷ 2 = 30 + 1;
- 30 ÷ 2 = 15 + 0;
- 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.
1 109 999 999 999 999 516(10) = 1111 0110 0111 1000 0011 0001 1110 0111 0100 1010 1110 1111 1110 0001 1100(2)
3. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 60.
- 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, 60,
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:
1 109 999 999 999 999 516(10) Base 10 integer number converted and written as a signed binary code (in base 2):
1 109 999 999 999 999 516(10) = 0000 1111 0110 0111 1000 0011 0001 1110 0111 0100 1010 1110 1111 1110 0001 1100
Spaces were used to group digits: for binary, by 4, for decimal, by 3.