What are the required steps to convert base 10 integer
number 101 010 101 011 010 172 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;
- 101 010 101 011 010 172 ÷ 2 = 50 505 050 505 505 086 + 0;
- 50 505 050 505 505 086 ÷ 2 = 25 252 525 252 752 543 + 0;
- 25 252 525 252 752 543 ÷ 2 = 12 626 262 626 376 271 + 1;
- 12 626 262 626 376 271 ÷ 2 = 6 313 131 313 188 135 + 1;
- 6 313 131 313 188 135 ÷ 2 = 3 156 565 656 594 067 + 1;
- 3 156 565 656 594 067 ÷ 2 = 1 578 282 828 297 033 + 1;
- 1 578 282 828 297 033 ÷ 2 = 789 141 414 148 516 + 1;
- 789 141 414 148 516 ÷ 2 = 394 570 707 074 258 + 0;
- 394 570 707 074 258 ÷ 2 = 197 285 353 537 129 + 0;
- 197 285 353 537 129 ÷ 2 = 98 642 676 768 564 + 1;
- 98 642 676 768 564 ÷ 2 = 49 321 338 384 282 + 0;
- 49 321 338 384 282 ÷ 2 = 24 660 669 192 141 + 0;
- 24 660 669 192 141 ÷ 2 = 12 330 334 596 070 + 1;
- 12 330 334 596 070 ÷ 2 = 6 165 167 298 035 + 0;
- 6 165 167 298 035 ÷ 2 = 3 082 583 649 017 + 1;
- 3 082 583 649 017 ÷ 2 = 1 541 291 824 508 + 1;
- 1 541 291 824 508 ÷ 2 = 770 645 912 254 + 0;
- 770 645 912 254 ÷ 2 = 385 322 956 127 + 0;
- 385 322 956 127 ÷ 2 = 192 661 478 063 + 1;
- 192 661 478 063 ÷ 2 = 96 330 739 031 + 1;
- 96 330 739 031 ÷ 2 = 48 165 369 515 + 1;
- 48 165 369 515 ÷ 2 = 24 082 684 757 + 1;
- 24 082 684 757 ÷ 2 = 12 041 342 378 + 1;
- 12 041 342 378 ÷ 2 = 6 020 671 189 + 0;
- 6 020 671 189 ÷ 2 = 3 010 335 594 + 1;
- 3 010 335 594 ÷ 2 = 1 505 167 797 + 0;
- 1 505 167 797 ÷ 2 = 752 583 898 + 1;
- 752 583 898 ÷ 2 = 376 291 949 + 0;
- 376 291 949 ÷ 2 = 188 145 974 + 1;
- 188 145 974 ÷ 2 = 94 072 987 + 0;
- 94 072 987 ÷ 2 = 47 036 493 + 1;
- 47 036 493 ÷ 2 = 23 518 246 + 1;
- 23 518 246 ÷ 2 = 11 759 123 + 0;
- 11 759 123 ÷ 2 = 5 879 561 + 1;
- 5 879 561 ÷ 2 = 2 939 780 + 1;
- 2 939 780 ÷ 2 = 1 469 890 + 0;
- 1 469 890 ÷ 2 = 734 945 + 0;
- 734 945 ÷ 2 = 367 472 + 1;
- 367 472 ÷ 2 = 183 736 + 0;
- 183 736 ÷ 2 = 91 868 + 0;
- 91 868 ÷ 2 = 45 934 + 0;
- 45 934 ÷ 2 = 22 967 + 0;
- 22 967 ÷ 2 = 11 483 + 1;
- 11 483 ÷ 2 = 5 741 + 1;
- 5 741 ÷ 2 = 2 870 + 1;
- 2 870 ÷ 2 = 1 435 + 0;
- 1 435 ÷ 2 = 717 + 1;
- 717 ÷ 2 = 358 + 1;
- 358 ÷ 2 = 179 + 0;
- 179 ÷ 2 = 89 + 1;
- 89 ÷ 2 = 44 + 1;
- 44 ÷ 2 = 22 + 0;
- 22 ÷ 2 = 11 + 0;
- 11 ÷ 2 = 5 + 1;
- 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.
101 010 101 011 010 172(10) = 1 0110 0110 1101 1100 0010 0110 1101 0101 0111 1100 1101 0010 0111 1100(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:
101 010 101 011 010 172(10) Base 10 integer number converted and written as a signed binary code (in base 2):
101 010 101 011 010 172(10) = 0000 0001 0110 0110 1101 1100 0010 0110 1101 0101 0111 1100 1101 0010 0111 1100
Spaces were used to group digits: for binary, by 4, for decimal, by 3.