What are the required steps to convert base 10 integer
number 1 000 111 101 010 099 508 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 000 111 101 010 099 508 ÷ 2 = 500 055 550 505 049 754 + 0;
- 500 055 550 505 049 754 ÷ 2 = 250 027 775 252 524 877 + 0;
- 250 027 775 252 524 877 ÷ 2 = 125 013 887 626 262 438 + 1;
- 125 013 887 626 262 438 ÷ 2 = 62 506 943 813 131 219 + 0;
- 62 506 943 813 131 219 ÷ 2 = 31 253 471 906 565 609 + 1;
- 31 253 471 906 565 609 ÷ 2 = 15 626 735 953 282 804 + 1;
- 15 626 735 953 282 804 ÷ 2 = 7 813 367 976 641 402 + 0;
- 7 813 367 976 641 402 ÷ 2 = 3 906 683 988 320 701 + 0;
- 3 906 683 988 320 701 ÷ 2 = 1 953 341 994 160 350 + 1;
- 1 953 341 994 160 350 ÷ 2 = 976 670 997 080 175 + 0;
- 976 670 997 080 175 ÷ 2 = 488 335 498 540 087 + 1;
- 488 335 498 540 087 ÷ 2 = 244 167 749 270 043 + 1;
- 244 167 749 270 043 ÷ 2 = 122 083 874 635 021 + 1;
- 122 083 874 635 021 ÷ 2 = 61 041 937 317 510 + 1;
- 61 041 937 317 510 ÷ 2 = 30 520 968 658 755 + 0;
- 30 520 968 658 755 ÷ 2 = 15 260 484 329 377 + 1;
- 15 260 484 329 377 ÷ 2 = 7 630 242 164 688 + 1;
- 7 630 242 164 688 ÷ 2 = 3 815 121 082 344 + 0;
- 3 815 121 082 344 ÷ 2 = 1 907 560 541 172 + 0;
- 1 907 560 541 172 ÷ 2 = 953 780 270 586 + 0;
- 953 780 270 586 ÷ 2 = 476 890 135 293 + 0;
- 476 890 135 293 ÷ 2 = 238 445 067 646 + 1;
- 238 445 067 646 ÷ 2 = 119 222 533 823 + 0;
- 119 222 533 823 ÷ 2 = 59 611 266 911 + 1;
- 59 611 266 911 ÷ 2 = 29 805 633 455 + 1;
- 29 805 633 455 ÷ 2 = 14 902 816 727 + 1;
- 14 902 816 727 ÷ 2 = 7 451 408 363 + 1;
- 7 451 408 363 ÷ 2 = 3 725 704 181 + 1;
- 3 725 704 181 ÷ 2 = 1 862 852 090 + 1;
- 1 862 852 090 ÷ 2 = 931 426 045 + 0;
- 931 426 045 ÷ 2 = 465 713 022 + 1;
- 465 713 022 ÷ 2 = 232 856 511 + 0;
- 232 856 511 ÷ 2 = 116 428 255 + 1;
- 116 428 255 ÷ 2 = 58 214 127 + 1;
- 58 214 127 ÷ 2 = 29 107 063 + 1;
- 29 107 063 ÷ 2 = 14 553 531 + 1;
- 14 553 531 ÷ 2 = 7 276 765 + 1;
- 7 276 765 ÷ 2 = 3 638 382 + 1;
- 3 638 382 ÷ 2 = 1 819 191 + 0;
- 1 819 191 ÷ 2 = 909 595 + 1;
- 909 595 ÷ 2 = 454 797 + 1;
- 454 797 ÷ 2 = 227 398 + 1;
- 227 398 ÷ 2 = 113 699 + 0;
- 113 699 ÷ 2 = 56 849 + 1;
- 56 849 ÷ 2 = 28 424 + 1;
- 28 424 ÷ 2 = 14 212 + 0;
- 14 212 ÷ 2 = 7 106 + 0;
- 7 106 ÷ 2 = 3 553 + 0;
- 3 553 ÷ 2 = 1 776 + 1;
- 1 776 ÷ 2 = 888 + 0;
- 888 ÷ 2 = 444 + 0;
- 444 ÷ 2 = 222 + 0;
- 222 ÷ 2 = 111 + 0;
- 111 ÷ 2 = 55 + 1;
- 55 ÷ 2 = 27 + 1;
- 27 ÷ 2 = 13 + 1;
- 13 ÷ 2 = 6 + 1;
- 6 ÷ 2 = 3 + 0;
- 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.
1 000 111 101 010 099 508(10) = 1101 1110 0001 0001 1011 1011 1111 0101 1111 1010 0001 1011 1101 0011 0100(2)
3. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 60.
- 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, 60,
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 000 111 101 010 099 508(10) Base 10 integer number converted and written as a signed binary code (in base 2):
1 000 111 101 010 099 508(10) = 0000 1101 1110 0001 0001 1011 1011 1111 0101 1111 1010 0001 1011 1101 0011 0100
Spaces were used to group digits: for binary, by 4, for decimal, by 3.