What are the required steps to convert base 10 integer
number 2 382 496 205 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;
- 2 382 496 205 ÷ 2 = 1 191 248 102 + 1;
- 1 191 248 102 ÷ 2 = 595 624 051 + 0;
- 595 624 051 ÷ 2 = 297 812 025 + 1;
- 297 812 025 ÷ 2 = 148 906 012 + 1;
- 148 906 012 ÷ 2 = 74 453 006 + 0;
- 74 453 006 ÷ 2 = 37 226 503 + 0;
- 37 226 503 ÷ 2 = 18 613 251 + 1;
- 18 613 251 ÷ 2 = 9 306 625 + 1;
- 9 306 625 ÷ 2 = 4 653 312 + 1;
- 4 653 312 ÷ 2 = 2 326 656 + 0;
- 2 326 656 ÷ 2 = 1 163 328 + 0;
- 1 163 328 ÷ 2 = 581 664 + 0;
- 581 664 ÷ 2 = 290 832 + 0;
- 290 832 ÷ 2 = 145 416 + 0;
- 145 416 ÷ 2 = 72 708 + 0;
- 72 708 ÷ 2 = 36 354 + 0;
- 36 354 ÷ 2 = 18 177 + 0;
- 18 177 ÷ 2 = 9 088 + 1;
- 9 088 ÷ 2 = 4 544 + 0;
- 4 544 ÷ 2 = 2 272 + 0;
- 2 272 ÷ 2 = 1 136 + 0;
- 1 136 ÷ 2 = 568 + 0;
- 568 ÷ 2 = 284 + 0;
- 284 ÷ 2 = 142 + 0;
- 142 ÷ 2 = 71 + 0;
- 71 ÷ 2 = 35 + 1;
- 35 ÷ 2 = 17 + 1;
- 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.
2 382 496 205(10) = 1000 1110 0000 0010 0000 0001 1100 1101(2)
3. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 32.
- 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, 32,
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:
2 382 496 205(10) Base 10 integer number converted and written as a signed binary code (in base 2):
2 382 496 205(10) = 0000 0000 0000 0000 0000 0000 0000 0000 1000 1110 0000 0010 0000 0001 1100 1101
Spaces were used to group digits: for binary, by 4, for decimal, by 3.