What are the required steps to convert base 10 integer
number 180 420 031 709 542 833 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;
- 180 420 031 709 542 833 ÷ 2 = 90 210 015 854 771 416 + 1;
- 90 210 015 854 771 416 ÷ 2 = 45 105 007 927 385 708 + 0;
- 45 105 007 927 385 708 ÷ 2 = 22 552 503 963 692 854 + 0;
- 22 552 503 963 692 854 ÷ 2 = 11 276 251 981 846 427 + 0;
- 11 276 251 981 846 427 ÷ 2 = 5 638 125 990 923 213 + 1;
- 5 638 125 990 923 213 ÷ 2 = 2 819 062 995 461 606 + 1;
- 2 819 062 995 461 606 ÷ 2 = 1 409 531 497 730 803 + 0;
- 1 409 531 497 730 803 ÷ 2 = 704 765 748 865 401 + 1;
- 704 765 748 865 401 ÷ 2 = 352 382 874 432 700 + 1;
- 352 382 874 432 700 ÷ 2 = 176 191 437 216 350 + 0;
- 176 191 437 216 350 ÷ 2 = 88 095 718 608 175 + 0;
- 88 095 718 608 175 ÷ 2 = 44 047 859 304 087 + 1;
- 44 047 859 304 087 ÷ 2 = 22 023 929 652 043 + 1;
- 22 023 929 652 043 ÷ 2 = 11 011 964 826 021 + 1;
- 11 011 964 826 021 ÷ 2 = 5 505 982 413 010 + 1;
- 5 505 982 413 010 ÷ 2 = 2 752 991 206 505 + 0;
- 2 752 991 206 505 ÷ 2 = 1 376 495 603 252 + 1;
- 1 376 495 603 252 ÷ 2 = 688 247 801 626 + 0;
- 688 247 801 626 ÷ 2 = 344 123 900 813 + 0;
- 344 123 900 813 ÷ 2 = 172 061 950 406 + 1;
- 172 061 950 406 ÷ 2 = 86 030 975 203 + 0;
- 86 030 975 203 ÷ 2 = 43 015 487 601 + 1;
- 43 015 487 601 ÷ 2 = 21 507 743 800 + 1;
- 21 507 743 800 ÷ 2 = 10 753 871 900 + 0;
- 10 753 871 900 ÷ 2 = 5 376 935 950 + 0;
- 5 376 935 950 ÷ 2 = 2 688 467 975 + 0;
- 2 688 467 975 ÷ 2 = 1 344 233 987 + 1;
- 1 344 233 987 ÷ 2 = 672 116 993 + 1;
- 672 116 993 ÷ 2 = 336 058 496 + 1;
- 336 058 496 ÷ 2 = 168 029 248 + 0;
- 168 029 248 ÷ 2 = 84 014 624 + 0;
- 84 014 624 ÷ 2 = 42 007 312 + 0;
- 42 007 312 ÷ 2 = 21 003 656 + 0;
- 21 003 656 ÷ 2 = 10 501 828 + 0;
- 10 501 828 ÷ 2 = 5 250 914 + 0;
- 5 250 914 ÷ 2 = 2 625 457 + 0;
- 2 625 457 ÷ 2 = 1 312 728 + 1;
- 1 312 728 ÷ 2 = 656 364 + 0;
- 656 364 ÷ 2 = 328 182 + 0;
- 328 182 ÷ 2 = 164 091 + 0;
- 164 091 ÷ 2 = 82 045 + 1;
- 82 045 ÷ 2 = 41 022 + 1;
- 41 022 ÷ 2 = 20 511 + 0;
- 20 511 ÷ 2 = 10 255 + 1;
- 10 255 ÷ 2 = 5 127 + 1;
- 5 127 ÷ 2 = 2 563 + 1;
- 2 563 ÷ 2 = 1 281 + 1;
- 1 281 ÷ 2 = 640 + 1;
- 640 ÷ 2 = 320 + 0;
- 320 ÷ 2 = 160 + 0;
- 160 ÷ 2 = 80 + 0;
- 80 ÷ 2 = 40 + 0;
- 40 ÷ 2 = 20 + 0;
- 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.
180 420 031 709 542 833(10) = 10 1000 0000 1111 1011 0001 0000 0001 1100 0110 1001 0111 1001 1011 0001(2)
3. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 58.
- 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, 58,
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:
180 420 031 709 542 833(10) Base 10 integer number converted and written as a signed binary code (in base 2):
180 420 031 709 542 833(10) = 0000 0010 1000 0000 1111 1011 0001 0000 0001 1100 0110 1001 0111 1001 1011 0001
Spaces were used to group digits: for binary, by 4, for decimal, by 3.