What are the required steps to convert base 10 integer
number -7 170 171 891 066 907 405 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:
|-7 170 171 891 066 907 405| = 7 170 171 891 066 907 405
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;
- 7 170 171 891 066 907 405 ÷ 2 = 3 585 085 945 533 453 702 + 1;
- 3 585 085 945 533 453 702 ÷ 2 = 1 792 542 972 766 726 851 + 0;
- 1 792 542 972 766 726 851 ÷ 2 = 896 271 486 383 363 425 + 1;
- 896 271 486 383 363 425 ÷ 2 = 448 135 743 191 681 712 + 1;
- 448 135 743 191 681 712 ÷ 2 = 224 067 871 595 840 856 + 0;
- 224 067 871 595 840 856 ÷ 2 = 112 033 935 797 920 428 + 0;
- 112 033 935 797 920 428 ÷ 2 = 56 016 967 898 960 214 + 0;
- 56 016 967 898 960 214 ÷ 2 = 28 008 483 949 480 107 + 0;
- 28 008 483 949 480 107 ÷ 2 = 14 004 241 974 740 053 + 1;
- 14 004 241 974 740 053 ÷ 2 = 7 002 120 987 370 026 + 1;
- 7 002 120 987 370 026 ÷ 2 = 3 501 060 493 685 013 + 0;
- 3 501 060 493 685 013 ÷ 2 = 1 750 530 246 842 506 + 1;
- 1 750 530 246 842 506 ÷ 2 = 875 265 123 421 253 + 0;
- 875 265 123 421 253 ÷ 2 = 437 632 561 710 626 + 1;
- 437 632 561 710 626 ÷ 2 = 218 816 280 855 313 + 0;
- 218 816 280 855 313 ÷ 2 = 109 408 140 427 656 + 1;
- 109 408 140 427 656 ÷ 2 = 54 704 070 213 828 + 0;
- 54 704 070 213 828 ÷ 2 = 27 352 035 106 914 + 0;
- 27 352 035 106 914 ÷ 2 = 13 676 017 553 457 + 0;
- 13 676 017 553 457 ÷ 2 = 6 838 008 776 728 + 1;
- 6 838 008 776 728 ÷ 2 = 3 419 004 388 364 + 0;
- 3 419 004 388 364 ÷ 2 = 1 709 502 194 182 + 0;
- 1 709 502 194 182 ÷ 2 = 854 751 097 091 + 0;
- 854 751 097 091 ÷ 2 = 427 375 548 545 + 1;
- 427 375 548 545 ÷ 2 = 213 687 774 272 + 1;
- 213 687 774 272 ÷ 2 = 106 843 887 136 + 0;
- 106 843 887 136 ÷ 2 = 53 421 943 568 + 0;
- 53 421 943 568 ÷ 2 = 26 710 971 784 + 0;
- 26 710 971 784 ÷ 2 = 13 355 485 892 + 0;
- 13 355 485 892 ÷ 2 = 6 677 742 946 + 0;
- 6 677 742 946 ÷ 2 = 3 338 871 473 + 0;
- 3 338 871 473 ÷ 2 = 1 669 435 736 + 1;
- 1 669 435 736 ÷ 2 = 834 717 868 + 0;
- 834 717 868 ÷ 2 = 417 358 934 + 0;
- 417 358 934 ÷ 2 = 208 679 467 + 0;
- 208 679 467 ÷ 2 = 104 339 733 + 1;
- 104 339 733 ÷ 2 = 52 169 866 + 1;
- 52 169 866 ÷ 2 = 26 084 933 + 0;
- 26 084 933 ÷ 2 = 13 042 466 + 1;
- 13 042 466 ÷ 2 = 6 521 233 + 0;
- 6 521 233 ÷ 2 = 3 260 616 + 1;
- 3 260 616 ÷ 2 = 1 630 308 + 0;
- 1 630 308 ÷ 2 = 815 154 + 0;
- 815 154 ÷ 2 = 407 577 + 0;
- 407 577 ÷ 2 = 203 788 + 1;
- 203 788 ÷ 2 = 101 894 + 0;
- 101 894 ÷ 2 = 50 947 + 0;
- 50 947 ÷ 2 = 25 473 + 1;
- 25 473 ÷ 2 = 12 736 + 1;
- 12 736 ÷ 2 = 6 368 + 0;
- 6 368 ÷ 2 = 3 184 + 0;
- 3 184 ÷ 2 = 1 592 + 0;
- 1 592 ÷ 2 = 796 + 0;
- 796 ÷ 2 = 398 + 0;
- 398 ÷ 2 = 199 + 0;
- 199 ÷ 2 = 99 + 1;
- 99 ÷ 2 = 49 + 1;
- 49 ÷ 2 = 24 + 1;
- 24 ÷ 2 = 12 + 0;
- 12 ÷ 2 = 6 + 0;
- 6 ÷ 2 = 3 + 0;
- 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.
7 170 171 891 066 907 405(10) = 110 0011 1000 0001 1001 0001 0101 1000 1000 0001 1000 1000 1010 1011 0000 1101(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:
7 170 171 891 066 907 405(10) = 0110 0011 1000 0001 1001 0001 0101 1000 1000 0001 1000 1000 1010 1011 0000 1101
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...
-7 170 171 891 066 907 405(10) Base 10 integer number converted and written as a signed binary code (in base 2):
-7 170 171 891 066 907 405(10) = 1110 0011 1000 0001 1001 0001 0101 1000 1000 0001 1000 1000 1010 1011 0000 1101
Spaces were used to group digits: for binary, by 4, for decimal, by 3.