What are the required steps to convert base 10 integer
number -1 110 001 010 169 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. Start with the positive version of the number:
|-1 110 001 010 169| = 1 110 001 010 169
2. 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 110 001 010 169 ÷ 2 = 555 000 505 084 + 1;
- 555 000 505 084 ÷ 2 = 277 500 252 542 + 0;
- 277 500 252 542 ÷ 2 = 138 750 126 271 + 0;
- 138 750 126 271 ÷ 2 = 69 375 063 135 + 1;
- 69 375 063 135 ÷ 2 = 34 687 531 567 + 1;
- 34 687 531 567 ÷ 2 = 17 343 765 783 + 1;
- 17 343 765 783 ÷ 2 = 8 671 882 891 + 1;
- 8 671 882 891 ÷ 2 = 4 335 941 445 + 1;
- 4 335 941 445 ÷ 2 = 2 167 970 722 + 1;
- 2 167 970 722 ÷ 2 = 1 083 985 361 + 0;
- 1 083 985 361 ÷ 2 = 541 992 680 + 1;
- 541 992 680 ÷ 2 = 270 996 340 + 0;
- 270 996 340 ÷ 2 = 135 498 170 + 0;
- 135 498 170 ÷ 2 = 67 749 085 + 0;
- 67 749 085 ÷ 2 = 33 874 542 + 1;
- 33 874 542 ÷ 2 = 16 937 271 + 0;
- 16 937 271 ÷ 2 = 8 468 635 + 1;
- 8 468 635 ÷ 2 = 4 234 317 + 1;
- 4 234 317 ÷ 2 = 2 117 158 + 1;
- 2 117 158 ÷ 2 = 1 058 579 + 0;
- 1 058 579 ÷ 2 = 529 289 + 1;
- 529 289 ÷ 2 = 264 644 + 1;
- 264 644 ÷ 2 = 132 322 + 0;
- 132 322 ÷ 2 = 66 161 + 0;
- 66 161 ÷ 2 = 33 080 + 1;
- 33 080 ÷ 2 = 16 540 + 0;
- 16 540 ÷ 2 = 8 270 + 0;
- 8 270 ÷ 2 = 4 135 + 0;
- 4 135 ÷ 2 = 2 067 + 1;
- 2 067 ÷ 2 = 1 033 + 1;
- 1 033 ÷ 2 = 516 + 1;
- 516 ÷ 2 = 258 + 0;
- 258 ÷ 2 = 129 + 0;
- 129 ÷ 2 = 64 + 1;
- 64 ÷ 2 = 32 + 0;
- 32 ÷ 2 = 16 + 0;
- 16 ÷ 2 = 8 + 0;
- 8 ÷ 2 = 4 + 0;
- 4 ÷ 2 = 2 + 0;
- 2 ÷ 2 = 1 + 0;
- 1 ÷ 2 = 0 + 1;
3. Construct the base 2 representation of the positive number:
Take all the remainders starting from the bottom of the list constructed above.
1 110 001 010 169(10) = 1 0000 0010 0111 0001 0011 0111 0100 0101 1111 1001(2)
4. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 41.
- 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, 41,
3) so that the first bit (leftmost) could be zero
(we deal with a positive number at this moment)
=== is: 64.
5. 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:
1 110 001 010 169(10) = 0000 0000 0000 0000 0000 0001 0000 0010 0111 0001 0011 0111 0100 0101 1111 1001
6. Get the negative integer number representation:
To get the negative integer number representation on 64 bits (8 Bytes),
... change the first bit (the leftmost), from 0 to 1...
-1 110 001 010 169(10) Base 10 integer number converted and written as a signed binary code (in base 2):
-1 110 001 010 169(10) = 1000 0000 0000 0000 0000 0001 0000 0010 0111 0001 0011 0111 0100 0101 1111 1001
Spaces were used to group digits: for binary, by 4, for decimal, by 3.