What are the required steps to convert base 10 integer
number 878 787 421 709 541 022 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;
- 878 787 421 709 541 022 ÷ 2 = 439 393 710 854 770 511 + 0;
- 439 393 710 854 770 511 ÷ 2 = 219 696 855 427 385 255 + 1;
- 219 696 855 427 385 255 ÷ 2 = 109 848 427 713 692 627 + 1;
- 109 848 427 713 692 627 ÷ 2 = 54 924 213 856 846 313 + 1;
- 54 924 213 856 846 313 ÷ 2 = 27 462 106 928 423 156 + 1;
- 27 462 106 928 423 156 ÷ 2 = 13 731 053 464 211 578 + 0;
- 13 731 053 464 211 578 ÷ 2 = 6 865 526 732 105 789 + 0;
- 6 865 526 732 105 789 ÷ 2 = 3 432 763 366 052 894 + 1;
- 3 432 763 366 052 894 ÷ 2 = 1 716 381 683 026 447 + 0;
- 1 716 381 683 026 447 ÷ 2 = 858 190 841 513 223 + 1;
- 858 190 841 513 223 ÷ 2 = 429 095 420 756 611 + 1;
- 429 095 420 756 611 ÷ 2 = 214 547 710 378 305 + 1;
- 214 547 710 378 305 ÷ 2 = 107 273 855 189 152 + 1;
- 107 273 855 189 152 ÷ 2 = 53 636 927 594 576 + 0;
- 53 636 927 594 576 ÷ 2 = 26 818 463 797 288 + 0;
- 26 818 463 797 288 ÷ 2 = 13 409 231 898 644 + 0;
- 13 409 231 898 644 ÷ 2 = 6 704 615 949 322 + 0;
- 6 704 615 949 322 ÷ 2 = 3 352 307 974 661 + 0;
- 3 352 307 974 661 ÷ 2 = 1 676 153 987 330 + 1;
- 1 676 153 987 330 ÷ 2 = 838 076 993 665 + 0;
- 838 076 993 665 ÷ 2 = 419 038 496 832 + 1;
- 419 038 496 832 ÷ 2 = 209 519 248 416 + 0;
- 209 519 248 416 ÷ 2 = 104 759 624 208 + 0;
- 104 759 624 208 ÷ 2 = 52 379 812 104 + 0;
- 52 379 812 104 ÷ 2 = 26 189 906 052 + 0;
- 26 189 906 052 ÷ 2 = 13 094 953 026 + 0;
- 13 094 953 026 ÷ 2 = 6 547 476 513 + 0;
- 6 547 476 513 ÷ 2 = 3 273 738 256 + 1;
- 3 273 738 256 ÷ 2 = 1 636 869 128 + 0;
- 1 636 869 128 ÷ 2 = 818 434 564 + 0;
- 818 434 564 ÷ 2 = 409 217 282 + 0;
- 409 217 282 ÷ 2 = 204 608 641 + 0;
- 204 608 641 ÷ 2 = 102 304 320 + 1;
- 102 304 320 ÷ 2 = 51 152 160 + 0;
- 51 152 160 ÷ 2 = 25 576 080 + 0;
- 25 576 080 ÷ 2 = 12 788 040 + 0;
- 12 788 040 ÷ 2 = 6 394 020 + 0;
- 6 394 020 ÷ 2 = 3 197 010 + 0;
- 3 197 010 ÷ 2 = 1 598 505 + 0;
- 1 598 505 ÷ 2 = 799 252 + 1;
- 799 252 ÷ 2 = 399 626 + 0;
- 399 626 ÷ 2 = 199 813 + 0;
- 199 813 ÷ 2 = 99 906 + 1;
- 99 906 ÷ 2 = 49 953 + 0;
- 49 953 ÷ 2 = 24 976 + 1;
- 24 976 ÷ 2 = 12 488 + 0;
- 12 488 ÷ 2 = 6 244 + 0;
- 6 244 ÷ 2 = 3 122 + 0;
- 3 122 ÷ 2 = 1 561 + 0;
- 1 561 ÷ 2 = 780 + 1;
- 780 ÷ 2 = 390 + 0;
- 390 ÷ 2 = 195 + 0;
- 195 ÷ 2 = 97 + 1;
- 97 ÷ 2 = 48 + 1;
- 48 ÷ 2 = 24 + 0;
- 24 ÷ 2 = 12 + 0;
- 12 ÷ 2 = 6 + 0;
- 6 ÷ 2 = 3 + 0;
- 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.
878 787 421 709 541 022(10) = 1100 0011 0010 0001 0100 1000 0001 0000 1000 0001 0100 0001 1110 1001 1110(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:
878 787 421 709 541 022(10) Base 10 integer number converted and written as a signed binary code (in base 2):
878 787 421 709 541 022(10) = 0000 1100 0011 0010 0001 0100 1000 0001 0000 1000 0001 0100 0001 1110 1001 1110
Spaces were used to group digits: for binary, by 4, for decimal, by 3.