What are the required steps to convert base 10 integer
number 11 010 110 100 203 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;
- 11 010 110 100 203 ÷ 2 = 5 505 055 050 101 + 1;
- 5 505 055 050 101 ÷ 2 = 2 752 527 525 050 + 1;
- 2 752 527 525 050 ÷ 2 = 1 376 263 762 525 + 0;
- 1 376 263 762 525 ÷ 2 = 688 131 881 262 + 1;
- 688 131 881 262 ÷ 2 = 344 065 940 631 + 0;
- 344 065 940 631 ÷ 2 = 172 032 970 315 + 1;
- 172 032 970 315 ÷ 2 = 86 016 485 157 + 1;
- 86 016 485 157 ÷ 2 = 43 008 242 578 + 1;
- 43 008 242 578 ÷ 2 = 21 504 121 289 + 0;
- 21 504 121 289 ÷ 2 = 10 752 060 644 + 1;
- 10 752 060 644 ÷ 2 = 5 376 030 322 + 0;
- 5 376 030 322 ÷ 2 = 2 688 015 161 + 0;
- 2 688 015 161 ÷ 2 = 1 344 007 580 + 1;
- 1 344 007 580 ÷ 2 = 672 003 790 + 0;
- 672 003 790 ÷ 2 = 336 001 895 + 0;
- 336 001 895 ÷ 2 = 168 000 947 + 1;
- 168 000 947 ÷ 2 = 84 000 473 + 1;
- 84 000 473 ÷ 2 = 42 000 236 + 1;
- 42 000 236 ÷ 2 = 21 000 118 + 0;
- 21 000 118 ÷ 2 = 10 500 059 + 0;
- 10 500 059 ÷ 2 = 5 250 029 + 1;
- 5 250 029 ÷ 2 = 2 625 014 + 1;
- 2 625 014 ÷ 2 = 1 312 507 + 0;
- 1 312 507 ÷ 2 = 656 253 + 1;
- 656 253 ÷ 2 = 328 126 + 1;
- 328 126 ÷ 2 = 164 063 + 0;
- 164 063 ÷ 2 = 82 031 + 1;
- 82 031 ÷ 2 = 41 015 + 1;
- 41 015 ÷ 2 = 20 507 + 1;
- 20 507 ÷ 2 = 10 253 + 1;
- 10 253 ÷ 2 = 5 126 + 1;
- 5 126 ÷ 2 = 2 563 + 0;
- 2 563 ÷ 2 = 1 281 + 1;
- 1 281 ÷ 2 = 640 + 1;
- 640 ÷ 2 = 320 + 0;
- 320 ÷ 2 = 160 + 0;
- 160 ÷ 2 = 80 + 0;
- 80 ÷ 2 = 40 + 0;
- 40 ÷ 2 = 20 + 0;
- 20 ÷ 2 = 10 + 0;
- 10 ÷ 2 = 5 + 0;
- 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.
11 010 110 100 203(10) = 1010 0000 0011 0111 1101 1011 0011 1001 0010 1110 1011(2)
3. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 44.
- 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, 44,
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:
11 010 110 100 203(10) Base 10 integer number converted and written as a signed binary code (in base 2):
11 010 110 100 203(10) = 0000 0000 0000 0000 0000 1010 0000 0011 0111 1101 1011 0011 1001 0010 1110 1011
Spaces were used to group digits: for binary, by 4, for decimal, by 3.