What are the required steps to convert base 10 integer
number -9 022 270 416 445 046 026 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 022 270 416 445 046 026| = 9 022 270 416 445 046 026
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 022 270 416 445 046 026 ÷ 2 = 4 511 135 208 222 523 013 + 0;
- 4 511 135 208 222 523 013 ÷ 2 = 2 255 567 604 111 261 506 + 1;
- 2 255 567 604 111 261 506 ÷ 2 = 1 127 783 802 055 630 753 + 0;
- 1 127 783 802 055 630 753 ÷ 2 = 563 891 901 027 815 376 + 1;
- 563 891 901 027 815 376 ÷ 2 = 281 945 950 513 907 688 + 0;
- 281 945 950 513 907 688 ÷ 2 = 140 972 975 256 953 844 + 0;
- 140 972 975 256 953 844 ÷ 2 = 70 486 487 628 476 922 + 0;
- 70 486 487 628 476 922 ÷ 2 = 35 243 243 814 238 461 + 0;
- 35 243 243 814 238 461 ÷ 2 = 17 621 621 907 119 230 + 1;
- 17 621 621 907 119 230 ÷ 2 = 8 810 810 953 559 615 + 0;
- 8 810 810 953 559 615 ÷ 2 = 4 405 405 476 779 807 + 1;
- 4 405 405 476 779 807 ÷ 2 = 2 202 702 738 389 903 + 1;
- 2 202 702 738 389 903 ÷ 2 = 1 101 351 369 194 951 + 1;
- 1 101 351 369 194 951 ÷ 2 = 550 675 684 597 475 + 1;
- 550 675 684 597 475 ÷ 2 = 275 337 842 298 737 + 1;
- 275 337 842 298 737 ÷ 2 = 137 668 921 149 368 + 1;
- 137 668 921 149 368 ÷ 2 = 68 834 460 574 684 + 0;
- 68 834 460 574 684 ÷ 2 = 34 417 230 287 342 + 0;
- 34 417 230 287 342 ÷ 2 = 17 208 615 143 671 + 0;
- 17 208 615 143 671 ÷ 2 = 8 604 307 571 835 + 1;
- 8 604 307 571 835 ÷ 2 = 4 302 153 785 917 + 1;
- 4 302 153 785 917 ÷ 2 = 2 151 076 892 958 + 1;
- 2 151 076 892 958 ÷ 2 = 1 075 538 446 479 + 0;
- 1 075 538 446 479 ÷ 2 = 537 769 223 239 + 1;
- 537 769 223 239 ÷ 2 = 268 884 611 619 + 1;
- 268 884 611 619 ÷ 2 = 134 442 305 809 + 1;
- 134 442 305 809 ÷ 2 = 67 221 152 904 + 1;
- 67 221 152 904 ÷ 2 = 33 610 576 452 + 0;
- 33 610 576 452 ÷ 2 = 16 805 288 226 + 0;
- 16 805 288 226 ÷ 2 = 8 402 644 113 + 0;
- 8 402 644 113 ÷ 2 = 4 201 322 056 + 1;
- 4 201 322 056 ÷ 2 = 2 100 661 028 + 0;
- 2 100 661 028 ÷ 2 = 1 050 330 514 + 0;
- 1 050 330 514 ÷ 2 = 525 165 257 + 0;
- 525 165 257 ÷ 2 = 262 582 628 + 1;
- 262 582 628 ÷ 2 = 131 291 314 + 0;
- 131 291 314 ÷ 2 = 65 645 657 + 0;
- 65 645 657 ÷ 2 = 32 822 828 + 1;
- 32 822 828 ÷ 2 = 16 411 414 + 0;
- 16 411 414 ÷ 2 = 8 205 707 + 0;
- 8 205 707 ÷ 2 = 4 102 853 + 1;
- 4 102 853 ÷ 2 = 2 051 426 + 1;
- 2 051 426 ÷ 2 = 1 025 713 + 0;
- 1 025 713 ÷ 2 = 512 856 + 1;
- 512 856 ÷ 2 = 256 428 + 0;
- 256 428 ÷ 2 = 128 214 + 0;
- 128 214 ÷ 2 = 64 107 + 0;
- 64 107 ÷ 2 = 32 053 + 1;
- 32 053 ÷ 2 = 16 026 + 1;
- 16 026 ÷ 2 = 8 013 + 0;
- 8 013 ÷ 2 = 4 006 + 1;
- 4 006 ÷ 2 = 2 003 + 0;
- 2 003 ÷ 2 = 1 001 + 1;
- 1 001 ÷ 2 = 500 + 1;
- 500 ÷ 2 = 250 + 0;
- 250 ÷ 2 = 125 + 0;
- 125 ÷ 2 = 62 + 1;
- 62 ÷ 2 = 31 + 0;
- 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 022 270 416 445 046 026(10) = 111 1101 0011 0101 1000 1011 0010 0100 0100 0111 1011 1000 1111 1101 0000 1010(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 022 270 416 445 046 026(10) = 0111 1101 0011 0101 1000 1011 0010 0100 0100 0111 1011 1000 1111 1101 0000 1010
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 022 270 416 445 046 026(10) Base 10 integer number converted and written as a signed binary code (in base 2):
-9 022 270 416 445 046 026(10) = 1111 1101 0011 0101 1000 1011 0010 0100 0100 0111 1011 1000 1111 1101 0000 1010
Spaces were used to group digits: for binary, by 4, for decimal, by 3.