What are the required steps to convert base 10 integer
number 1 811 028 052 430 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;
- 1 811 028 052 430 ÷ 2 = 905 514 026 215 + 0;
- 905 514 026 215 ÷ 2 = 452 757 013 107 + 1;
- 452 757 013 107 ÷ 2 = 226 378 506 553 + 1;
- 226 378 506 553 ÷ 2 = 113 189 253 276 + 1;
- 113 189 253 276 ÷ 2 = 56 594 626 638 + 0;
- 56 594 626 638 ÷ 2 = 28 297 313 319 + 0;
- 28 297 313 319 ÷ 2 = 14 148 656 659 + 1;
- 14 148 656 659 ÷ 2 = 7 074 328 329 + 1;
- 7 074 328 329 ÷ 2 = 3 537 164 164 + 1;
- 3 537 164 164 ÷ 2 = 1 768 582 082 + 0;
- 1 768 582 082 ÷ 2 = 884 291 041 + 0;
- 884 291 041 ÷ 2 = 442 145 520 + 1;
- 442 145 520 ÷ 2 = 221 072 760 + 0;
- 221 072 760 ÷ 2 = 110 536 380 + 0;
- 110 536 380 ÷ 2 = 55 268 190 + 0;
- 55 268 190 ÷ 2 = 27 634 095 + 0;
- 27 634 095 ÷ 2 = 13 817 047 + 1;
- 13 817 047 ÷ 2 = 6 908 523 + 1;
- 6 908 523 ÷ 2 = 3 454 261 + 1;
- 3 454 261 ÷ 2 = 1 727 130 + 1;
- 1 727 130 ÷ 2 = 863 565 + 0;
- 863 565 ÷ 2 = 431 782 + 1;
- 431 782 ÷ 2 = 215 891 + 0;
- 215 891 ÷ 2 = 107 945 + 1;
- 107 945 ÷ 2 = 53 972 + 1;
- 53 972 ÷ 2 = 26 986 + 0;
- 26 986 ÷ 2 = 13 493 + 0;
- 13 493 ÷ 2 = 6 746 + 1;
- 6 746 ÷ 2 = 3 373 + 0;
- 3 373 ÷ 2 = 1 686 + 1;
- 1 686 ÷ 2 = 843 + 0;
- 843 ÷ 2 = 421 + 1;
- 421 ÷ 2 = 210 + 1;
- 210 ÷ 2 = 105 + 0;
- 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.
1 811 028 052 430(10) = 1 1010 0101 1010 1001 1010 1111 0000 1001 1100 1110(2)
3. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 41.
- 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, 41,
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:
1 811 028 052 430(10) Base 10 integer number converted and written as a signed binary code (in base 2):
1 811 028 052 430(10) = 0000 0000 0000 0000 0000 0001 1010 0101 1010 1001 1010 1111 0000 1001 1100 1110
Spaces were used to group digits: for binary, by 4, for decimal, by 3.