What are the required steps to convert base 10 integer
number -9 099 822 131 033 658 980 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. Start with the positive version of the number:
|-9 099 822 131 033 658 980| = 9 099 822 131 033 658 980
2. 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;
- 9 099 822 131 033 658 980 ÷ 2 = 4 549 911 065 516 829 490 + 0;
- 4 549 911 065 516 829 490 ÷ 2 = 2 274 955 532 758 414 745 + 0;
- 2 274 955 532 758 414 745 ÷ 2 = 1 137 477 766 379 207 372 + 1;
- 1 137 477 766 379 207 372 ÷ 2 = 568 738 883 189 603 686 + 0;
- 568 738 883 189 603 686 ÷ 2 = 284 369 441 594 801 843 + 0;
- 284 369 441 594 801 843 ÷ 2 = 142 184 720 797 400 921 + 1;
- 142 184 720 797 400 921 ÷ 2 = 71 092 360 398 700 460 + 1;
- 71 092 360 398 700 460 ÷ 2 = 35 546 180 199 350 230 + 0;
- 35 546 180 199 350 230 ÷ 2 = 17 773 090 099 675 115 + 0;
- 17 773 090 099 675 115 ÷ 2 = 8 886 545 049 837 557 + 1;
- 8 886 545 049 837 557 ÷ 2 = 4 443 272 524 918 778 + 1;
- 4 443 272 524 918 778 ÷ 2 = 2 221 636 262 459 389 + 0;
- 2 221 636 262 459 389 ÷ 2 = 1 110 818 131 229 694 + 1;
- 1 110 818 131 229 694 ÷ 2 = 555 409 065 614 847 + 0;
- 555 409 065 614 847 ÷ 2 = 277 704 532 807 423 + 1;
- 277 704 532 807 423 ÷ 2 = 138 852 266 403 711 + 1;
- 138 852 266 403 711 ÷ 2 = 69 426 133 201 855 + 1;
- 69 426 133 201 855 ÷ 2 = 34 713 066 600 927 + 1;
- 34 713 066 600 927 ÷ 2 = 17 356 533 300 463 + 1;
- 17 356 533 300 463 ÷ 2 = 8 678 266 650 231 + 1;
- 8 678 266 650 231 ÷ 2 = 4 339 133 325 115 + 1;
- 4 339 133 325 115 ÷ 2 = 2 169 566 662 557 + 1;
- 2 169 566 662 557 ÷ 2 = 1 084 783 331 278 + 1;
- 1 084 783 331 278 ÷ 2 = 542 391 665 639 + 0;
- 542 391 665 639 ÷ 2 = 271 195 832 819 + 1;
- 271 195 832 819 ÷ 2 = 135 597 916 409 + 1;
- 135 597 916 409 ÷ 2 = 67 798 958 204 + 1;
- 67 798 958 204 ÷ 2 = 33 899 479 102 + 0;
- 33 899 479 102 ÷ 2 = 16 949 739 551 + 0;
- 16 949 739 551 ÷ 2 = 8 474 869 775 + 1;
- 8 474 869 775 ÷ 2 = 4 237 434 887 + 1;
- 4 237 434 887 ÷ 2 = 2 118 717 443 + 1;
- 2 118 717 443 ÷ 2 = 1 059 358 721 + 1;
- 1 059 358 721 ÷ 2 = 529 679 360 + 1;
- 529 679 360 ÷ 2 = 264 839 680 + 0;
- 264 839 680 ÷ 2 = 132 419 840 + 0;
- 132 419 840 ÷ 2 = 66 209 920 + 0;
- 66 209 920 ÷ 2 = 33 104 960 + 0;
- 33 104 960 ÷ 2 = 16 552 480 + 0;
- 16 552 480 ÷ 2 = 8 276 240 + 0;
- 8 276 240 ÷ 2 = 4 138 120 + 0;
- 4 138 120 ÷ 2 = 2 069 060 + 0;
- 2 069 060 ÷ 2 = 1 034 530 + 0;
- 1 034 530 ÷ 2 = 517 265 + 0;
- 517 265 ÷ 2 = 258 632 + 1;
- 258 632 ÷ 2 = 129 316 + 0;
- 129 316 ÷ 2 = 64 658 + 0;
- 64 658 ÷ 2 = 32 329 + 0;
- 32 329 ÷ 2 = 16 164 + 1;
- 16 164 ÷ 2 = 8 082 + 0;
- 8 082 ÷ 2 = 4 041 + 0;
- 4 041 ÷ 2 = 2 020 + 1;
- 2 020 ÷ 2 = 1 010 + 0;
- 1 010 ÷ 2 = 505 + 0;
- 505 ÷ 2 = 252 + 1;
- 252 ÷ 2 = 126 + 0;
- 126 ÷ 2 = 63 + 0;
- 63 ÷ 2 = 31 + 1;
- 31 ÷ 2 = 15 + 1;
- 15 ÷ 2 = 7 + 1;
- 7 ÷ 2 = 3 + 1;
- 3 ÷ 2 = 1 + 1;
- 1 ÷ 2 = 0 + 1;
3. Construct the base 2 representation of the positive number:
Take all the remainders starting from the bottom of the list constructed above.
9 099 822 131 033 658 980(10) = 111 1110 0100 1001 0001 0000 0000 0011 1110 0111 0111 1111 1101 0110 0110 0100(2)
4. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 63.
- 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, 63,
3) so that the first bit (leftmost) could be zero
(we deal with a positive number at this moment)
=== is: 64.
5. 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:
9 099 822 131 033 658 980(10) = 0111 1110 0100 1001 0001 0000 0000 0011 1110 0111 0111 1111 1101 0110 0110 0100
6. Get the negative integer number representation:
To get the negative integer number representation on 64 bits (8 Bytes),
... change the first bit (the leftmost), from 0 to 1...
-9 099 822 131 033 658 980(10) Base 10 integer number converted and written as a signed binary code (in base 2):
-9 099 822 131 033 658 980(10) = 1111 1110 0100 1001 0001 0000 0000 0011 1110 0111 0111 1111 1101 0110 0110 0100
Spaces were used to group digits: for binary, by 4, for decimal, by 3.