What are the required steps to convert base 10 integer
number 29 823 579 136 480 031 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;
- 29 823 579 136 480 031 ÷ 2 = 14 911 789 568 240 015 + 1;
- 14 911 789 568 240 015 ÷ 2 = 7 455 894 784 120 007 + 1;
- 7 455 894 784 120 007 ÷ 2 = 3 727 947 392 060 003 + 1;
- 3 727 947 392 060 003 ÷ 2 = 1 863 973 696 030 001 + 1;
- 1 863 973 696 030 001 ÷ 2 = 931 986 848 015 000 + 1;
- 931 986 848 015 000 ÷ 2 = 465 993 424 007 500 + 0;
- 465 993 424 007 500 ÷ 2 = 232 996 712 003 750 + 0;
- 232 996 712 003 750 ÷ 2 = 116 498 356 001 875 + 0;
- 116 498 356 001 875 ÷ 2 = 58 249 178 000 937 + 1;
- 58 249 178 000 937 ÷ 2 = 29 124 589 000 468 + 1;
- 29 124 589 000 468 ÷ 2 = 14 562 294 500 234 + 0;
- 14 562 294 500 234 ÷ 2 = 7 281 147 250 117 + 0;
- 7 281 147 250 117 ÷ 2 = 3 640 573 625 058 + 1;
- 3 640 573 625 058 ÷ 2 = 1 820 286 812 529 + 0;
- 1 820 286 812 529 ÷ 2 = 910 143 406 264 + 1;
- 910 143 406 264 ÷ 2 = 455 071 703 132 + 0;
- 455 071 703 132 ÷ 2 = 227 535 851 566 + 0;
- 227 535 851 566 ÷ 2 = 113 767 925 783 + 0;
- 113 767 925 783 ÷ 2 = 56 883 962 891 + 1;
- 56 883 962 891 ÷ 2 = 28 441 981 445 + 1;
- 28 441 981 445 ÷ 2 = 14 220 990 722 + 1;
- 14 220 990 722 ÷ 2 = 7 110 495 361 + 0;
- 7 110 495 361 ÷ 2 = 3 555 247 680 + 1;
- 3 555 247 680 ÷ 2 = 1 777 623 840 + 0;
- 1 777 623 840 ÷ 2 = 888 811 920 + 0;
- 888 811 920 ÷ 2 = 444 405 960 + 0;
- 444 405 960 ÷ 2 = 222 202 980 + 0;
- 222 202 980 ÷ 2 = 111 101 490 + 0;
- 111 101 490 ÷ 2 = 55 550 745 + 0;
- 55 550 745 ÷ 2 = 27 775 372 + 1;
- 27 775 372 ÷ 2 = 13 887 686 + 0;
- 13 887 686 ÷ 2 = 6 943 843 + 0;
- 6 943 843 ÷ 2 = 3 471 921 + 1;
- 3 471 921 ÷ 2 = 1 735 960 + 1;
- 1 735 960 ÷ 2 = 867 980 + 0;
- 867 980 ÷ 2 = 433 990 + 0;
- 433 990 ÷ 2 = 216 995 + 0;
- 216 995 ÷ 2 = 108 497 + 1;
- 108 497 ÷ 2 = 54 248 + 1;
- 54 248 ÷ 2 = 27 124 + 0;
- 27 124 ÷ 2 = 13 562 + 0;
- 13 562 ÷ 2 = 6 781 + 0;
- 6 781 ÷ 2 = 3 390 + 1;
- 3 390 ÷ 2 = 1 695 + 0;
- 1 695 ÷ 2 = 847 + 1;
- 847 ÷ 2 = 423 + 1;
- 423 ÷ 2 = 211 + 1;
- 211 ÷ 2 = 105 + 1;
- 105 ÷ 2 = 52 + 1;
- 52 ÷ 2 = 26 + 0;
- 26 ÷ 2 = 13 + 0;
- 13 ÷ 2 = 6 + 1;
- 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.
29 823 579 136 480 031(10) = 110 1001 1111 0100 0110 0011 0010 0000 0101 1100 0101 0011 0001 1111(2)
3. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 55.
- 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, 55,
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:
29 823 579 136 480 031(10) Base 10 integer number converted and written as a signed binary code (in base 2):
29 823 579 136 480 031(10) = 0000 0000 0110 1001 1111 0100 0110 0011 0010 0000 0101 1100 0101 0011 0001 1111
Spaces were used to group digits: for binary, by 4, for decimal, by 3.