What are the required steps to convert base 10 integer
number 817 295 821 709 539 787 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;
- 817 295 821 709 539 787 ÷ 2 = 408 647 910 854 769 893 + 1;
- 408 647 910 854 769 893 ÷ 2 = 204 323 955 427 384 946 + 1;
- 204 323 955 427 384 946 ÷ 2 = 102 161 977 713 692 473 + 0;
- 102 161 977 713 692 473 ÷ 2 = 51 080 988 856 846 236 + 1;
- 51 080 988 856 846 236 ÷ 2 = 25 540 494 428 423 118 + 0;
- 25 540 494 428 423 118 ÷ 2 = 12 770 247 214 211 559 + 0;
- 12 770 247 214 211 559 ÷ 2 = 6 385 123 607 105 779 + 1;
- 6 385 123 607 105 779 ÷ 2 = 3 192 561 803 552 889 + 1;
- 3 192 561 803 552 889 ÷ 2 = 1 596 280 901 776 444 + 1;
- 1 596 280 901 776 444 ÷ 2 = 798 140 450 888 222 + 0;
- 798 140 450 888 222 ÷ 2 = 399 070 225 444 111 + 0;
- 399 070 225 444 111 ÷ 2 = 199 535 112 722 055 + 1;
- 199 535 112 722 055 ÷ 2 = 99 767 556 361 027 + 1;
- 99 767 556 361 027 ÷ 2 = 49 883 778 180 513 + 1;
- 49 883 778 180 513 ÷ 2 = 24 941 889 090 256 + 1;
- 24 941 889 090 256 ÷ 2 = 12 470 944 545 128 + 0;
- 12 470 944 545 128 ÷ 2 = 6 235 472 272 564 + 0;
- 6 235 472 272 564 ÷ 2 = 3 117 736 136 282 + 0;
- 3 117 736 136 282 ÷ 2 = 1 558 868 068 141 + 0;
- 1 558 868 068 141 ÷ 2 = 779 434 034 070 + 1;
- 779 434 034 070 ÷ 2 = 389 717 017 035 + 0;
- 389 717 017 035 ÷ 2 = 194 858 508 517 + 1;
- 194 858 508 517 ÷ 2 = 97 429 254 258 + 1;
- 97 429 254 258 ÷ 2 = 48 714 627 129 + 0;
- 48 714 627 129 ÷ 2 = 24 357 313 564 + 1;
- 24 357 313 564 ÷ 2 = 12 178 656 782 + 0;
- 12 178 656 782 ÷ 2 = 6 089 328 391 + 0;
- 6 089 328 391 ÷ 2 = 3 044 664 195 + 1;
- 3 044 664 195 ÷ 2 = 1 522 332 097 + 1;
- 1 522 332 097 ÷ 2 = 761 166 048 + 1;
- 761 166 048 ÷ 2 = 380 583 024 + 0;
- 380 583 024 ÷ 2 = 190 291 512 + 0;
- 190 291 512 ÷ 2 = 95 145 756 + 0;
- 95 145 756 ÷ 2 = 47 572 878 + 0;
- 47 572 878 ÷ 2 = 23 786 439 + 0;
- 23 786 439 ÷ 2 = 11 893 219 + 1;
- 11 893 219 ÷ 2 = 5 946 609 + 1;
- 5 946 609 ÷ 2 = 2 973 304 + 1;
- 2 973 304 ÷ 2 = 1 486 652 + 0;
- 1 486 652 ÷ 2 = 743 326 + 0;
- 743 326 ÷ 2 = 371 663 + 0;
- 371 663 ÷ 2 = 185 831 + 1;
- 185 831 ÷ 2 = 92 915 + 1;
- 92 915 ÷ 2 = 46 457 + 1;
- 46 457 ÷ 2 = 23 228 + 1;
- 23 228 ÷ 2 = 11 614 + 0;
- 11 614 ÷ 2 = 5 807 + 0;
- 5 807 ÷ 2 = 2 903 + 1;
- 2 903 ÷ 2 = 1 451 + 1;
- 1 451 ÷ 2 = 725 + 1;
- 725 ÷ 2 = 362 + 1;
- 362 ÷ 2 = 181 + 0;
- 181 ÷ 2 = 90 + 1;
- 90 ÷ 2 = 45 + 0;
- 45 ÷ 2 = 22 + 1;
- 22 ÷ 2 = 11 + 0;
- 11 ÷ 2 = 5 + 1;
- 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.
817 295 821 709 539 787(10) = 1011 0101 0111 1001 1110 0011 1000 0011 1001 0110 1000 0111 1001 1100 1011(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:
817 295 821 709 539 787(10) Base 10 integer number converted and written as a signed binary code (in base 2):
817 295 821 709 539 787(10) = 0000 1011 0101 0111 1001 1110 0011 1000 0011 1001 0110 1000 0111 1001 1100 1011
Spaces were used to group digits: for binary, by 4, for decimal, by 3.