What are the required steps to convert base 10 integer
number 1 560 905 691 880 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 560 905 691 880 ÷ 2 = 780 452 845 940 + 0;
- 780 452 845 940 ÷ 2 = 390 226 422 970 + 0;
- 390 226 422 970 ÷ 2 = 195 113 211 485 + 0;
- 195 113 211 485 ÷ 2 = 97 556 605 742 + 1;
- 97 556 605 742 ÷ 2 = 48 778 302 871 + 0;
- 48 778 302 871 ÷ 2 = 24 389 151 435 + 1;
- 24 389 151 435 ÷ 2 = 12 194 575 717 + 1;
- 12 194 575 717 ÷ 2 = 6 097 287 858 + 1;
- 6 097 287 858 ÷ 2 = 3 048 643 929 + 0;
- 3 048 643 929 ÷ 2 = 1 524 321 964 + 1;
- 1 524 321 964 ÷ 2 = 762 160 982 + 0;
- 762 160 982 ÷ 2 = 381 080 491 + 0;
- 381 080 491 ÷ 2 = 190 540 245 + 1;
- 190 540 245 ÷ 2 = 95 270 122 + 1;
- 95 270 122 ÷ 2 = 47 635 061 + 0;
- 47 635 061 ÷ 2 = 23 817 530 + 1;
- 23 817 530 ÷ 2 = 11 908 765 + 0;
- 11 908 765 ÷ 2 = 5 954 382 + 1;
- 5 954 382 ÷ 2 = 2 977 191 + 0;
- 2 977 191 ÷ 2 = 1 488 595 + 1;
- 1 488 595 ÷ 2 = 744 297 + 1;
- 744 297 ÷ 2 = 372 148 + 1;
- 372 148 ÷ 2 = 186 074 + 0;
- 186 074 ÷ 2 = 93 037 + 0;
- 93 037 ÷ 2 = 46 518 + 1;
- 46 518 ÷ 2 = 23 259 + 0;
- 23 259 ÷ 2 = 11 629 + 1;
- 11 629 ÷ 2 = 5 814 + 1;
- 5 814 ÷ 2 = 2 907 + 0;
- 2 907 ÷ 2 = 1 453 + 1;
- 1 453 ÷ 2 = 726 + 1;
- 726 ÷ 2 = 363 + 0;
- 363 ÷ 2 = 181 + 1;
- 181 ÷ 2 = 90 + 1;
- 90 ÷ 2 = 45 + 0;
- 45 ÷ 2 = 22 + 1;
- 22 ÷ 2 = 11 + 0;
- 11 ÷ 2 = 5 + 1;
- 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.
1 560 905 691 880(10) = 1 0110 1011 0110 1101 0011 1010 1011 0010 1110 1000(2)
3. 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.
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:
1 560 905 691 880(10) Base 10 integer number converted and written as a signed binary code (in base 2):
1 560 905 691 880(10) = 0000 0000 0000 0000 0000 0001 0110 1011 0110 1101 0011 1010 1011 0010 1110 1000
Spaces were used to group digits: for binary, by 4, for decimal, by 3.