What are the required steps to convert base 10 integer
number 343 434 907 305 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;
- 343 434 907 305 ÷ 2 = 171 717 453 652 + 1;
- 171 717 453 652 ÷ 2 = 85 858 726 826 + 0;
- 85 858 726 826 ÷ 2 = 42 929 363 413 + 0;
- 42 929 363 413 ÷ 2 = 21 464 681 706 + 1;
- 21 464 681 706 ÷ 2 = 10 732 340 853 + 0;
- 10 732 340 853 ÷ 2 = 5 366 170 426 + 1;
- 5 366 170 426 ÷ 2 = 2 683 085 213 + 0;
- 2 683 085 213 ÷ 2 = 1 341 542 606 + 1;
- 1 341 542 606 ÷ 2 = 670 771 303 + 0;
- 670 771 303 ÷ 2 = 335 385 651 + 1;
- 335 385 651 ÷ 2 = 167 692 825 + 1;
- 167 692 825 ÷ 2 = 83 846 412 + 1;
- 83 846 412 ÷ 2 = 41 923 206 + 0;
- 41 923 206 ÷ 2 = 20 961 603 + 0;
- 20 961 603 ÷ 2 = 10 480 801 + 1;
- 10 480 801 ÷ 2 = 5 240 400 + 1;
- 5 240 400 ÷ 2 = 2 620 200 + 0;
- 2 620 200 ÷ 2 = 1 310 100 + 0;
- 1 310 100 ÷ 2 = 655 050 + 0;
- 655 050 ÷ 2 = 327 525 + 0;
- 327 525 ÷ 2 = 163 762 + 1;
- 163 762 ÷ 2 = 81 881 + 0;
- 81 881 ÷ 2 = 40 940 + 1;
- 40 940 ÷ 2 = 20 470 + 0;
- 20 470 ÷ 2 = 10 235 + 0;
- 10 235 ÷ 2 = 5 117 + 1;
- 5 117 ÷ 2 = 2 558 + 1;
- 2 558 ÷ 2 = 1 279 + 0;
- 1 279 ÷ 2 = 639 + 1;
- 639 ÷ 2 = 319 + 1;
- 319 ÷ 2 = 159 + 1;
- 159 ÷ 2 = 79 + 1;
- 79 ÷ 2 = 39 + 1;
- 39 ÷ 2 = 19 + 1;
- 19 ÷ 2 = 9 + 1;
- 9 ÷ 2 = 4 + 1;
- 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.
343 434 907 305(10) = 100 1111 1111 0110 0101 0000 1100 1110 1010 1001(2)
3. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 39.
- 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, 39,
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:
343 434 907 305(10) Base 10 integer number converted and written as a signed binary code (in base 2):
343 434 907 305(10) = 0000 0000 0000 0000 0000 0000 0100 1111 1111 0110 0101 0000 1100 1110 1010 1001
Spaces were used to group digits: for binary, by 4, for decimal, by 3.