What are the required steps to convert base 10 integer
number 1 162 106 660 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 162 106 660 ÷ 2 = 581 053 330 + 0;
- 581 053 330 ÷ 2 = 290 526 665 + 0;
- 290 526 665 ÷ 2 = 145 263 332 + 1;
- 145 263 332 ÷ 2 = 72 631 666 + 0;
- 72 631 666 ÷ 2 = 36 315 833 + 0;
- 36 315 833 ÷ 2 = 18 157 916 + 1;
- 18 157 916 ÷ 2 = 9 078 958 + 0;
- 9 078 958 ÷ 2 = 4 539 479 + 0;
- 4 539 479 ÷ 2 = 2 269 739 + 1;
- 2 269 739 ÷ 2 = 1 134 869 + 1;
- 1 134 869 ÷ 2 = 567 434 + 1;
- 567 434 ÷ 2 = 283 717 + 0;
- 283 717 ÷ 2 = 141 858 + 1;
- 141 858 ÷ 2 = 70 929 + 0;
- 70 929 ÷ 2 = 35 464 + 1;
- 35 464 ÷ 2 = 17 732 + 0;
- 17 732 ÷ 2 = 8 866 + 0;
- 8 866 ÷ 2 = 4 433 + 0;
- 4 433 ÷ 2 = 2 216 + 1;
- 2 216 ÷ 2 = 1 108 + 0;
- 1 108 ÷ 2 = 554 + 0;
- 554 ÷ 2 = 277 + 0;
- 277 ÷ 2 = 138 + 1;
- 138 ÷ 2 = 69 + 0;
- 69 ÷ 2 = 34 + 1;
- 34 ÷ 2 = 17 + 0;
- 17 ÷ 2 = 8 + 1;
- 8 ÷ 2 = 4 + 0;
- 4 ÷ 2 = 2 + 0;
- 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.
1 162 106 660(10) = 100 0101 0100 0100 0101 0111 0010 0100(2)
3. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 31.
- 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, 31,
3) so that the first bit (leftmost) could be zero
(we deal with a positive number at this moment)
=== is: 32.
4. Get the positive binary computer representation on 32 bits (4 Bytes):
If needed, add extra 0s in front (to the left) of the base 2 number, up to the required length, 32:
1 162 106 660(10) Base 10 integer number converted and written as a signed binary code (in base 2):
1 162 106 660(10) = 0100 0101 0100 0100 0101 0111 0010 0100
Spaces were used to group digits: for binary, by 4, for decimal, by 3.