What are the required steps to convert base 10 integer
number 7 895 468 560 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;
- 7 895 468 560 ÷ 2 = 3 947 734 280 + 0;
- 3 947 734 280 ÷ 2 = 1 973 867 140 + 0;
- 1 973 867 140 ÷ 2 = 986 933 570 + 0;
- 986 933 570 ÷ 2 = 493 466 785 + 0;
- 493 466 785 ÷ 2 = 246 733 392 + 1;
- 246 733 392 ÷ 2 = 123 366 696 + 0;
- 123 366 696 ÷ 2 = 61 683 348 + 0;
- 61 683 348 ÷ 2 = 30 841 674 + 0;
- 30 841 674 ÷ 2 = 15 420 837 + 0;
- 15 420 837 ÷ 2 = 7 710 418 + 1;
- 7 710 418 ÷ 2 = 3 855 209 + 0;
- 3 855 209 ÷ 2 = 1 927 604 + 1;
- 1 927 604 ÷ 2 = 963 802 + 0;
- 963 802 ÷ 2 = 481 901 + 0;
- 481 901 ÷ 2 = 240 950 + 1;
- 240 950 ÷ 2 = 120 475 + 0;
- 120 475 ÷ 2 = 60 237 + 1;
- 60 237 ÷ 2 = 30 118 + 1;
- 30 118 ÷ 2 = 15 059 + 0;
- 15 059 ÷ 2 = 7 529 + 1;
- 7 529 ÷ 2 = 3 764 + 1;
- 3 764 ÷ 2 = 1 882 + 0;
- 1 882 ÷ 2 = 941 + 0;
- 941 ÷ 2 = 470 + 1;
- 470 ÷ 2 = 235 + 0;
- 235 ÷ 2 = 117 + 1;
- 117 ÷ 2 = 58 + 1;
- 58 ÷ 2 = 29 + 0;
- 29 ÷ 2 = 14 + 1;
- 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.
7 895 468 560(10) = 1 1101 0110 1001 1011 0100 1010 0001 0000(2)
3. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 33.
- 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, 33,
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:
7 895 468 560(10) Base 10 integer number converted and written as a signed binary code (in base 2):
7 895 468 560(10) = 0000 0000 0000 0000 0000 0000 0000 0001 1101 0110 1001 1011 0100 1010 0001 0000
Spaces were used to group digits: for binary, by 4, for decimal, by 3.