What are the required steps to convert base 10 integer
number 2 997 998 891 709 545 668 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;
- 2 997 998 891 709 545 668 ÷ 2 = 1 498 999 445 854 772 834 + 0;
- 1 498 999 445 854 772 834 ÷ 2 = 749 499 722 927 386 417 + 0;
- 749 499 722 927 386 417 ÷ 2 = 374 749 861 463 693 208 + 1;
- 374 749 861 463 693 208 ÷ 2 = 187 374 930 731 846 604 + 0;
- 187 374 930 731 846 604 ÷ 2 = 93 687 465 365 923 302 + 0;
- 93 687 465 365 923 302 ÷ 2 = 46 843 732 682 961 651 + 0;
- 46 843 732 682 961 651 ÷ 2 = 23 421 866 341 480 825 + 1;
- 23 421 866 341 480 825 ÷ 2 = 11 710 933 170 740 412 + 1;
- 11 710 933 170 740 412 ÷ 2 = 5 855 466 585 370 206 + 0;
- 5 855 466 585 370 206 ÷ 2 = 2 927 733 292 685 103 + 0;
- 2 927 733 292 685 103 ÷ 2 = 1 463 866 646 342 551 + 1;
- 1 463 866 646 342 551 ÷ 2 = 731 933 323 171 275 + 1;
- 731 933 323 171 275 ÷ 2 = 365 966 661 585 637 + 1;
- 365 966 661 585 637 ÷ 2 = 182 983 330 792 818 + 1;
- 182 983 330 792 818 ÷ 2 = 91 491 665 396 409 + 0;
- 91 491 665 396 409 ÷ 2 = 45 745 832 698 204 + 1;
- 45 745 832 698 204 ÷ 2 = 22 872 916 349 102 + 0;
- 22 872 916 349 102 ÷ 2 = 11 436 458 174 551 + 0;
- 11 436 458 174 551 ÷ 2 = 5 718 229 087 275 + 1;
- 5 718 229 087 275 ÷ 2 = 2 859 114 543 637 + 1;
- 2 859 114 543 637 ÷ 2 = 1 429 557 271 818 + 1;
- 1 429 557 271 818 ÷ 2 = 714 778 635 909 + 0;
- 714 778 635 909 ÷ 2 = 357 389 317 954 + 1;
- 357 389 317 954 ÷ 2 = 178 694 658 977 + 0;
- 178 694 658 977 ÷ 2 = 89 347 329 488 + 1;
- 89 347 329 488 ÷ 2 = 44 673 664 744 + 0;
- 44 673 664 744 ÷ 2 = 22 336 832 372 + 0;
- 22 336 832 372 ÷ 2 = 11 168 416 186 + 0;
- 11 168 416 186 ÷ 2 = 5 584 208 093 + 0;
- 5 584 208 093 ÷ 2 = 2 792 104 046 + 1;
- 2 792 104 046 ÷ 2 = 1 396 052 023 + 0;
- 1 396 052 023 ÷ 2 = 698 026 011 + 1;
- 698 026 011 ÷ 2 = 349 013 005 + 1;
- 349 013 005 ÷ 2 = 174 506 502 + 1;
- 174 506 502 ÷ 2 = 87 253 251 + 0;
- 87 253 251 ÷ 2 = 43 626 625 + 1;
- 43 626 625 ÷ 2 = 21 813 312 + 1;
- 21 813 312 ÷ 2 = 10 906 656 + 0;
- 10 906 656 ÷ 2 = 5 453 328 + 0;
- 5 453 328 ÷ 2 = 2 726 664 + 0;
- 2 726 664 ÷ 2 = 1 363 332 + 0;
- 1 363 332 ÷ 2 = 681 666 + 0;
- 681 666 ÷ 2 = 340 833 + 0;
- 340 833 ÷ 2 = 170 416 + 1;
- 170 416 ÷ 2 = 85 208 + 0;
- 85 208 ÷ 2 = 42 604 + 0;
- 42 604 ÷ 2 = 21 302 + 0;
- 21 302 ÷ 2 = 10 651 + 0;
- 10 651 ÷ 2 = 5 325 + 1;
- 5 325 ÷ 2 = 2 662 + 1;
- 2 662 ÷ 2 = 1 331 + 0;
- 1 331 ÷ 2 = 665 + 1;
- 665 ÷ 2 = 332 + 1;
- 332 ÷ 2 = 166 + 0;
- 166 ÷ 2 = 83 + 0;
- 83 ÷ 2 = 41 + 1;
- 41 ÷ 2 = 20 + 1;
- 20 ÷ 2 = 10 + 0;
- 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.
2 997 998 891 709 545 668(10) = 10 1001 1001 1011 0000 1000 0001 1011 1010 0001 0101 1100 1011 1100 1100 0100(2)
3. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 62.
- 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, 62,
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:
2 997 998 891 709 545 668(10) Base 10 integer number converted and written as a signed binary code (in base 2):
2 997 998 891 709 545 668(10) = 0010 1001 1001 1011 0000 1000 0001 1011 1010 0001 0101 1100 1011 1100 1100 0100
Spaces were used to group digits: for binary, by 4, for decimal, by 3.