What are the required steps to convert base 10 integer
number -8 441 850 790 118 254 670 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. Start with the positive version of the number:
|-8 441 850 790 118 254 670| = 8 441 850 790 118 254 670
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;
- 8 441 850 790 118 254 670 ÷ 2 = 4 220 925 395 059 127 335 + 0;
- 4 220 925 395 059 127 335 ÷ 2 = 2 110 462 697 529 563 667 + 1;
- 2 110 462 697 529 563 667 ÷ 2 = 1 055 231 348 764 781 833 + 1;
- 1 055 231 348 764 781 833 ÷ 2 = 527 615 674 382 390 916 + 1;
- 527 615 674 382 390 916 ÷ 2 = 263 807 837 191 195 458 + 0;
- 263 807 837 191 195 458 ÷ 2 = 131 903 918 595 597 729 + 0;
- 131 903 918 595 597 729 ÷ 2 = 65 951 959 297 798 864 + 1;
- 65 951 959 297 798 864 ÷ 2 = 32 975 979 648 899 432 + 0;
- 32 975 979 648 899 432 ÷ 2 = 16 487 989 824 449 716 + 0;
- 16 487 989 824 449 716 ÷ 2 = 8 243 994 912 224 858 + 0;
- 8 243 994 912 224 858 ÷ 2 = 4 121 997 456 112 429 + 0;
- 4 121 997 456 112 429 ÷ 2 = 2 060 998 728 056 214 + 1;
- 2 060 998 728 056 214 ÷ 2 = 1 030 499 364 028 107 + 0;
- 1 030 499 364 028 107 ÷ 2 = 515 249 682 014 053 + 1;
- 515 249 682 014 053 ÷ 2 = 257 624 841 007 026 + 1;
- 257 624 841 007 026 ÷ 2 = 128 812 420 503 513 + 0;
- 128 812 420 503 513 ÷ 2 = 64 406 210 251 756 + 1;
- 64 406 210 251 756 ÷ 2 = 32 203 105 125 878 + 0;
- 32 203 105 125 878 ÷ 2 = 16 101 552 562 939 + 0;
- 16 101 552 562 939 ÷ 2 = 8 050 776 281 469 + 1;
- 8 050 776 281 469 ÷ 2 = 4 025 388 140 734 + 1;
- 4 025 388 140 734 ÷ 2 = 2 012 694 070 367 + 0;
- 2 012 694 070 367 ÷ 2 = 1 006 347 035 183 + 1;
- 1 006 347 035 183 ÷ 2 = 503 173 517 591 + 1;
- 503 173 517 591 ÷ 2 = 251 586 758 795 + 1;
- 251 586 758 795 ÷ 2 = 125 793 379 397 + 1;
- 125 793 379 397 ÷ 2 = 62 896 689 698 + 1;
- 62 896 689 698 ÷ 2 = 31 448 344 849 + 0;
- 31 448 344 849 ÷ 2 = 15 724 172 424 + 1;
- 15 724 172 424 ÷ 2 = 7 862 086 212 + 0;
- 7 862 086 212 ÷ 2 = 3 931 043 106 + 0;
- 3 931 043 106 ÷ 2 = 1 965 521 553 + 0;
- 1 965 521 553 ÷ 2 = 982 760 776 + 1;
- 982 760 776 ÷ 2 = 491 380 388 + 0;
- 491 380 388 ÷ 2 = 245 690 194 + 0;
- 245 690 194 ÷ 2 = 122 845 097 + 0;
- 122 845 097 ÷ 2 = 61 422 548 + 1;
- 61 422 548 ÷ 2 = 30 711 274 + 0;
- 30 711 274 ÷ 2 = 15 355 637 + 0;
- 15 355 637 ÷ 2 = 7 677 818 + 1;
- 7 677 818 ÷ 2 = 3 838 909 + 0;
- 3 838 909 ÷ 2 = 1 919 454 + 1;
- 1 919 454 ÷ 2 = 959 727 + 0;
- 959 727 ÷ 2 = 479 863 + 1;
- 479 863 ÷ 2 = 239 931 + 1;
- 239 931 ÷ 2 = 119 965 + 1;
- 119 965 ÷ 2 = 59 982 + 1;
- 59 982 ÷ 2 = 29 991 + 0;
- 29 991 ÷ 2 = 14 995 + 1;
- 14 995 ÷ 2 = 7 497 + 1;
- 7 497 ÷ 2 = 3 748 + 1;
- 3 748 ÷ 2 = 1 874 + 0;
- 1 874 ÷ 2 = 937 + 0;
- 937 ÷ 2 = 468 + 1;
- 468 ÷ 2 = 234 + 0;
- 234 ÷ 2 = 117 + 0;
- 117 ÷ 2 = 58 + 1;
- 58 ÷ 2 = 29 + 0;
- 29 ÷ 2 = 14 + 1;
- 14 ÷ 2 = 7 + 0;
- 7 ÷ 2 = 3 + 1;
- 3 ÷ 2 = 1 + 1;
- 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.
8 441 850 790 118 254 670(10) = 111 0101 0010 0111 0111 1010 1001 0001 0001 0111 1101 1001 0110 1000 0100 1110(2)
4. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 63.
- 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, 63,
3) so that the first bit (leftmost) could be zero
(we deal with a positive number at this moment)
=== is: 64.
5. 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:
8 441 850 790 118 254 670(10) = 0111 0101 0010 0111 0111 1010 1001 0001 0001 0111 1101 1001 0110 1000 0100 1110
6. Get the negative integer number representation:
To get the negative integer number representation on 64 bits (8 Bytes),
... change the first bit (the leftmost), from 0 to 1...
-8 441 850 790 118 254 670(10) Base 10 integer number converted and written as a signed binary code (in base 2):
-8 441 850 790 118 254 670(10) = 1111 0101 0010 0111 0111 1010 1001 0001 0001 0111 1101 1001 0110 1000 0100 1110
Spaces were used to group digits: for binary, by 4, for decimal, by 3.