What are the required steps to convert base 10 integer
number 134 729 950 095 212 294 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;
- 134 729 950 095 212 294 ÷ 2 = 67 364 975 047 606 147 + 0;
- 67 364 975 047 606 147 ÷ 2 = 33 682 487 523 803 073 + 1;
- 33 682 487 523 803 073 ÷ 2 = 16 841 243 761 901 536 + 1;
- 16 841 243 761 901 536 ÷ 2 = 8 420 621 880 950 768 + 0;
- 8 420 621 880 950 768 ÷ 2 = 4 210 310 940 475 384 + 0;
- 4 210 310 940 475 384 ÷ 2 = 2 105 155 470 237 692 + 0;
- 2 105 155 470 237 692 ÷ 2 = 1 052 577 735 118 846 + 0;
- 1 052 577 735 118 846 ÷ 2 = 526 288 867 559 423 + 0;
- 526 288 867 559 423 ÷ 2 = 263 144 433 779 711 + 1;
- 263 144 433 779 711 ÷ 2 = 131 572 216 889 855 + 1;
- 131 572 216 889 855 ÷ 2 = 65 786 108 444 927 + 1;
- 65 786 108 444 927 ÷ 2 = 32 893 054 222 463 + 1;
- 32 893 054 222 463 ÷ 2 = 16 446 527 111 231 + 1;
- 16 446 527 111 231 ÷ 2 = 8 223 263 555 615 + 1;
- 8 223 263 555 615 ÷ 2 = 4 111 631 777 807 + 1;
- 4 111 631 777 807 ÷ 2 = 2 055 815 888 903 + 1;
- 2 055 815 888 903 ÷ 2 = 1 027 907 944 451 + 1;
- 1 027 907 944 451 ÷ 2 = 513 953 972 225 + 1;
- 513 953 972 225 ÷ 2 = 256 976 986 112 + 1;
- 256 976 986 112 ÷ 2 = 128 488 493 056 + 0;
- 128 488 493 056 ÷ 2 = 64 244 246 528 + 0;
- 64 244 246 528 ÷ 2 = 32 122 123 264 + 0;
- 32 122 123 264 ÷ 2 = 16 061 061 632 + 0;
- 16 061 061 632 ÷ 2 = 8 030 530 816 + 0;
- 8 030 530 816 ÷ 2 = 4 015 265 408 + 0;
- 4 015 265 408 ÷ 2 = 2 007 632 704 + 0;
- 2 007 632 704 ÷ 2 = 1 003 816 352 + 0;
- 1 003 816 352 ÷ 2 = 501 908 176 + 0;
- 501 908 176 ÷ 2 = 250 954 088 + 0;
- 250 954 088 ÷ 2 = 125 477 044 + 0;
- 125 477 044 ÷ 2 = 62 738 522 + 0;
- 62 738 522 ÷ 2 = 31 369 261 + 0;
- 31 369 261 ÷ 2 = 15 684 630 + 1;
- 15 684 630 ÷ 2 = 7 842 315 + 0;
- 7 842 315 ÷ 2 = 3 921 157 + 1;
- 3 921 157 ÷ 2 = 1 960 578 + 1;
- 1 960 578 ÷ 2 = 980 289 + 0;
- 980 289 ÷ 2 = 490 144 + 1;
- 490 144 ÷ 2 = 245 072 + 0;
- 245 072 ÷ 2 = 122 536 + 0;
- 122 536 ÷ 2 = 61 268 + 0;
- 61 268 ÷ 2 = 30 634 + 0;
- 30 634 ÷ 2 = 15 317 + 0;
- 15 317 ÷ 2 = 7 658 + 1;
- 7 658 ÷ 2 = 3 829 + 0;
- 3 829 ÷ 2 = 1 914 + 1;
- 1 914 ÷ 2 = 957 + 0;
- 957 ÷ 2 = 478 + 1;
- 478 ÷ 2 = 239 + 0;
- 239 ÷ 2 = 119 + 1;
- 119 ÷ 2 = 59 + 1;
- 59 ÷ 2 = 29 + 1;
- 29 ÷ 2 = 14 + 1;
- 14 ÷ 2 = 7 + 0;
- 7 ÷ 2 = 3 + 1;
- 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.
134 729 950 095 212 294(10) = 1 1101 1110 1010 1000 0010 1101 0000 0000 0000 0111 1111 1111 0000 0110(2)
3. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 57.
- 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, 57,
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:
134 729 950 095 212 294(10) Base 10 integer number converted and written as a signed binary code (in base 2):
134 729 950 095 212 294(10) = 0000 0001 1101 1110 1010 1000 0010 1101 0000 0000 0000 0111 1111 1111 0000 0110
Spaces were used to group digits: for binary, by 4, for decimal, by 3.