What are the required steps to convert base 10 integer
number 1 931 691 195 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 931 691 195 ÷ 2 = 965 845 597 + 1;
- 965 845 597 ÷ 2 = 482 922 798 + 1;
- 482 922 798 ÷ 2 = 241 461 399 + 0;
- 241 461 399 ÷ 2 = 120 730 699 + 1;
- 120 730 699 ÷ 2 = 60 365 349 + 1;
- 60 365 349 ÷ 2 = 30 182 674 + 1;
- 30 182 674 ÷ 2 = 15 091 337 + 0;
- 15 091 337 ÷ 2 = 7 545 668 + 1;
- 7 545 668 ÷ 2 = 3 772 834 + 0;
- 3 772 834 ÷ 2 = 1 886 417 + 0;
- 1 886 417 ÷ 2 = 943 208 + 1;
- 943 208 ÷ 2 = 471 604 + 0;
- 471 604 ÷ 2 = 235 802 + 0;
- 235 802 ÷ 2 = 117 901 + 0;
- 117 901 ÷ 2 = 58 950 + 1;
- 58 950 ÷ 2 = 29 475 + 0;
- 29 475 ÷ 2 = 14 737 + 1;
- 14 737 ÷ 2 = 7 368 + 1;
- 7 368 ÷ 2 = 3 684 + 0;
- 3 684 ÷ 2 = 1 842 + 0;
- 1 842 ÷ 2 = 921 + 0;
- 921 ÷ 2 = 460 + 1;
- 460 ÷ 2 = 230 + 0;
- 230 ÷ 2 = 115 + 0;
- 115 ÷ 2 = 57 + 1;
- 57 ÷ 2 = 28 + 1;
- 28 ÷ 2 = 14 + 0;
- 14 ÷ 2 = 7 + 0;
- 7 ÷ 2 = 3 + 1;
- 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 931 691 195(10) = 111 0011 0010 0011 0100 0100 1011 1011(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 931 691 195(10) Base 10 integer number converted and written as a signed binary code (in base 2):
1 931 691 195(10) = 0111 0011 0010 0011 0100 0100 1011 1011
Spaces were used to group digits: for binary, by 4, for decimal, by 3.