What are the required steps to convert base 10 integer
number -6 917 528 876 943 091 035 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:
|-6 917 528 876 943 091 035| = 6 917 528 876 943 091 035
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;
- 6 917 528 876 943 091 035 ÷ 2 = 3 458 764 438 471 545 517 + 1;
- 3 458 764 438 471 545 517 ÷ 2 = 1 729 382 219 235 772 758 + 1;
- 1 729 382 219 235 772 758 ÷ 2 = 864 691 109 617 886 379 + 0;
- 864 691 109 617 886 379 ÷ 2 = 432 345 554 808 943 189 + 1;
- 432 345 554 808 943 189 ÷ 2 = 216 172 777 404 471 594 + 1;
- 216 172 777 404 471 594 ÷ 2 = 108 086 388 702 235 797 + 0;
- 108 086 388 702 235 797 ÷ 2 = 54 043 194 351 117 898 + 1;
- 54 043 194 351 117 898 ÷ 2 = 27 021 597 175 558 949 + 0;
- 27 021 597 175 558 949 ÷ 2 = 13 510 798 587 779 474 + 1;
- 13 510 798 587 779 474 ÷ 2 = 6 755 399 293 889 737 + 0;
- 6 755 399 293 889 737 ÷ 2 = 3 377 699 646 944 868 + 1;
- 3 377 699 646 944 868 ÷ 2 = 1 688 849 823 472 434 + 0;
- 1 688 849 823 472 434 ÷ 2 = 844 424 911 736 217 + 0;
- 844 424 911 736 217 ÷ 2 = 422 212 455 868 108 + 1;
- 422 212 455 868 108 ÷ 2 = 211 106 227 934 054 + 0;
- 211 106 227 934 054 ÷ 2 = 105 553 113 967 027 + 0;
- 105 553 113 967 027 ÷ 2 = 52 776 556 983 513 + 1;
- 52 776 556 983 513 ÷ 2 = 26 388 278 491 756 + 1;
- 26 388 278 491 756 ÷ 2 = 13 194 139 245 878 + 0;
- 13 194 139 245 878 ÷ 2 = 6 597 069 622 939 + 0;
- 6 597 069 622 939 ÷ 2 = 3 298 534 811 469 + 1;
- 3 298 534 811 469 ÷ 2 = 1 649 267 405 734 + 1;
- 1 649 267 405 734 ÷ 2 = 824 633 702 867 + 0;
- 824 633 702 867 ÷ 2 = 412 316 851 433 + 1;
- 412 316 851 433 ÷ 2 = 206 158 425 716 + 1;
- 206 158 425 716 ÷ 2 = 103 079 212 858 + 0;
- 103 079 212 858 ÷ 2 = 51 539 606 429 + 0;
- 51 539 606 429 ÷ 2 = 25 769 803 214 + 1;
- 25 769 803 214 ÷ 2 = 12 884 901 607 + 0;
- 12 884 901 607 ÷ 2 = 6 442 450 803 + 1;
- 6 442 450 803 ÷ 2 = 3 221 225 401 + 1;
- 3 221 225 401 ÷ 2 = 1 610 612 700 + 1;
- 1 610 612 700 ÷ 2 = 805 306 350 + 0;
- 805 306 350 ÷ 2 = 402 653 175 + 0;
- 402 653 175 ÷ 2 = 201 326 587 + 1;
- 201 326 587 ÷ 2 = 100 663 293 + 1;
- 100 663 293 ÷ 2 = 50 331 646 + 1;
- 50 331 646 ÷ 2 = 25 165 823 + 0;
- 25 165 823 ÷ 2 = 12 582 911 + 1;
- 12 582 911 ÷ 2 = 6 291 455 + 1;
- 6 291 455 ÷ 2 = 3 145 727 + 1;
- 3 145 727 ÷ 2 = 1 572 863 + 1;
- 1 572 863 ÷ 2 = 786 431 + 1;
- 786 431 ÷ 2 = 393 215 + 1;
- 393 215 ÷ 2 = 196 607 + 1;
- 196 607 ÷ 2 = 98 303 + 1;
- 98 303 ÷ 2 = 49 151 + 1;
- 49 151 ÷ 2 = 24 575 + 1;
- 24 575 ÷ 2 = 12 287 + 1;
- 12 287 ÷ 2 = 6 143 + 1;
- 6 143 ÷ 2 = 3 071 + 1;
- 3 071 ÷ 2 = 1 535 + 1;
- 1 535 ÷ 2 = 767 + 1;
- 767 ÷ 2 = 383 + 1;
- 383 ÷ 2 = 191 + 1;
- 191 ÷ 2 = 95 + 1;
- 95 ÷ 2 = 47 + 1;
- 47 ÷ 2 = 23 + 1;
- 23 ÷ 2 = 11 + 1;
- 11 ÷ 2 = 5 + 1;
- 5 ÷ 2 = 2 + 1;
- 2 ÷ 2 = 1 + 0;
- 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.
6 917 528 876 943 091 035(10) = 101 1111 1111 1111 1111 1111 1101 1100 1110 1001 1011 0011 0010 0101 0101 1011(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:
6 917 528 876 943 091 035(10) = 0101 1111 1111 1111 1111 1111 1101 1100 1110 1001 1011 0011 0010 0101 0101 1011
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...
-6 917 528 876 943 091 035(10) Base 10 integer number converted and written as a signed binary code (in base 2):
-6 917 528 876 943 091 035(10) = 1101 1111 1111 1111 1111 1111 1101 1100 1110 1001 1011 0011 0010 0101 0101 1011
Spaces were used to group digits: for binary, by 4, for decimal, by 3.