What are the required steps to convert base 10 integer
number 100 101 010 099 577 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;
- 100 101 010 099 577 ÷ 2 = 50 050 505 049 788 + 1;
- 50 050 505 049 788 ÷ 2 = 25 025 252 524 894 + 0;
- 25 025 252 524 894 ÷ 2 = 12 512 626 262 447 + 0;
- 12 512 626 262 447 ÷ 2 = 6 256 313 131 223 + 1;
- 6 256 313 131 223 ÷ 2 = 3 128 156 565 611 + 1;
- 3 128 156 565 611 ÷ 2 = 1 564 078 282 805 + 1;
- 1 564 078 282 805 ÷ 2 = 782 039 141 402 + 1;
- 782 039 141 402 ÷ 2 = 391 019 570 701 + 0;
- 391 019 570 701 ÷ 2 = 195 509 785 350 + 1;
- 195 509 785 350 ÷ 2 = 97 754 892 675 + 0;
- 97 754 892 675 ÷ 2 = 48 877 446 337 + 1;
- 48 877 446 337 ÷ 2 = 24 438 723 168 + 1;
- 24 438 723 168 ÷ 2 = 12 219 361 584 + 0;
- 12 219 361 584 ÷ 2 = 6 109 680 792 + 0;
- 6 109 680 792 ÷ 2 = 3 054 840 396 + 0;
- 3 054 840 396 ÷ 2 = 1 527 420 198 + 0;
- 1 527 420 198 ÷ 2 = 763 710 099 + 0;
- 763 710 099 ÷ 2 = 381 855 049 + 1;
- 381 855 049 ÷ 2 = 190 927 524 + 1;
- 190 927 524 ÷ 2 = 95 463 762 + 0;
- 95 463 762 ÷ 2 = 47 731 881 + 0;
- 47 731 881 ÷ 2 = 23 865 940 + 1;
- 23 865 940 ÷ 2 = 11 932 970 + 0;
- 11 932 970 ÷ 2 = 5 966 485 + 0;
- 5 966 485 ÷ 2 = 2 983 242 + 1;
- 2 983 242 ÷ 2 = 1 491 621 + 0;
- 1 491 621 ÷ 2 = 745 810 + 1;
- 745 810 ÷ 2 = 372 905 + 0;
- 372 905 ÷ 2 = 186 452 + 1;
- 186 452 ÷ 2 = 93 226 + 0;
- 93 226 ÷ 2 = 46 613 + 0;
- 46 613 ÷ 2 = 23 306 + 1;
- 23 306 ÷ 2 = 11 653 + 0;
- 11 653 ÷ 2 = 5 826 + 1;
- 5 826 ÷ 2 = 2 913 + 0;
- 2 913 ÷ 2 = 1 456 + 1;
- 1 456 ÷ 2 = 728 + 0;
- 728 ÷ 2 = 364 + 0;
- 364 ÷ 2 = 182 + 0;
- 182 ÷ 2 = 91 + 0;
- 91 ÷ 2 = 45 + 1;
- 45 ÷ 2 = 22 + 1;
- 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.
100 101 010 099 577(10) = 101 1011 0000 1010 1001 0101 0010 0110 0000 1101 0111 1001(2)
3. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 47.
- 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, 47,
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:
100 101 010 099 577(10) Base 10 integer number converted and written as a signed binary code (in base 2):
100 101 010 099 577(10) = 0000 0000 0000 0000 0101 1011 0000 1010 1001 0101 0010 0110 0000 1101 0111 1001
Spaces were used to group digits: for binary, by 4, for decimal, by 3.