What are the required steps to convert base 10 integer
number -6 937 650 605 005 805 061 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 937 650 605 005 805 061| = 6 937 650 605 005 805 061
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 937 650 605 005 805 061 ÷ 2 = 3 468 825 302 502 902 530 + 1;
- 3 468 825 302 502 902 530 ÷ 2 = 1 734 412 651 251 451 265 + 0;
- 1 734 412 651 251 451 265 ÷ 2 = 867 206 325 625 725 632 + 1;
- 867 206 325 625 725 632 ÷ 2 = 433 603 162 812 862 816 + 0;
- 433 603 162 812 862 816 ÷ 2 = 216 801 581 406 431 408 + 0;
- 216 801 581 406 431 408 ÷ 2 = 108 400 790 703 215 704 + 0;
- 108 400 790 703 215 704 ÷ 2 = 54 200 395 351 607 852 + 0;
- 54 200 395 351 607 852 ÷ 2 = 27 100 197 675 803 926 + 0;
- 27 100 197 675 803 926 ÷ 2 = 13 550 098 837 901 963 + 0;
- 13 550 098 837 901 963 ÷ 2 = 6 775 049 418 950 981 + 1;
- 6 775 049 418 950 981 ÷ 2 = 3 387 524 709 475 490 + 1;
- 3 387 524 709 475 490 ÷ 2 = 1 693 762 354 737 745 + 0;
- 1 693 762 354 737 745 ÷ 2 = 846 881 177 368 872 + 1;
- 846 881 177 368 872 ÷ 2 = 423 440 588 684 436 + 0;
- 423 440 588 684 436 ÷ 2 = 211 720 294 342 218 + 0;
- 211 720 294 342 218 ÷ 2 = 105 860 147 171 109 + 0;
- 105 860 147 171 109 ÷ 2 = 52 930 073 585 554 + 1;
- 52 930 073 585 554 ÷ 2 = 26 465 036 792 777 + 0;
- 26 465 036 792 777 ÷ 2 = 13 232 518 396 388 + 1;
- 13 232 518 396 388 ÷ 2 = 6 616 259 198 194 + 0;
- 6 616 259 198 194 ÷ 2 = 3 308 129 599 097 + 0;
- 3 308 129 599 097 ÷ 2 = 1 654 064 799 548 + 1;
- 1 654 064 799 548 ÷ 2 = 827 032 399 774 + 0;
- 827 032 399 774 ÷ 2 = 413 516 199 887 + 0;
- 413 516 199 887 ÷ 2 = 206 758 099 943 + 1;
- 206 758 099 943 ÷ 2 = 103 379 049 971 + 1;
- 103 379 049 971 ÷ 2 = 51 689 524 985 + 1;
- 51 689 524 985 ÷ 2 = 25 844 762 492 + 1;
- 25 844 762 492 ÷ 2 = 12 922 381 246 + 0;
- 12 922 381 246 ÷ 2 = 6 461 190 623 + 0;
- 6 461 190 623 ÷ 2 = 3 230 595 311 + 1;
- 3 230 595 311 ÷ 2 = 1 615 297 655 + 1;
- 1 615 297 655 ÷ 2 = 807 648 827 + 1;
- 807 648 827 ÷ 2 = 403 824 413 + 1;
- 403 824 413 ÷ 2 = 201 912 206 + 1;
- 201 912 206 ÷ 2 = 100 956 103 + 0;
- 100 956 103 ÷ 2 = 50 478 051 + 1;
- 50 478 051 ÷ 2 = 25 239 025 + 1;
- 25 239 025 ÷ 2 = 12 619 512 + 1;
- 12 619 512 ÷ 2 = 6 309 756 + 0;
- 6 309 756 ÷ 2 = 3 154 878 + 0;
- 3 154 878 ÷ 2 = 1 577 439 + 0;
- 1 577 439 ÷ 2 = 788 719 + 1;
- 788 719 ÷ 2 = 394 359 + 1;
- 394 359 ÷ 2 = 197 179 + 1;
- 197 179 ÷ 2 = 98 589 + 1;
- 98 589 ÷ 2 = 49 294 + 1;
- 49 294 ÷ 2 = 24 647 + 0;
- 24 647 ÷ 2 = 12 323 + 1;
- 12 323 ÷ 2 = 6 161 + 1;
- 6 161 ÷ 2 = 3 080 + 1;
- 3 080 ÷ 2 = 1 540 + 0;
- 1 540 ÷ 2 = 770 + 0;
- 770 ÷ 2 = 385 + 0;
- 385 ÷ 2 = 192 + 1;
- 192 ÷ 2 = 96 + 0;
- 96 ÷ 2 = 48 + 0;
- 48 ÷ 2 = 24 + 0;
- 24 ÷ 2 = 12 + 0;
- 12 ÷ 2 = 6 + 0;
- 6 ÷ 2 = 3 + 0;
- 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.
6 937 650 605 005 805 061(10) = 110 0000 0100 0111 0111 1100 0111 0111 1100 1111 0010 0101 0001 0110 0000 0101(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 937 650 605 005 805 061(10) = 0110 0000 0100 0111 0111 1100 0111 0111 1100 1111 0010 0101 0001 0110 0000 0101
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 937 650 605 005 805 061(10) Base 10 integer number converted and written as a signed binary code (in base 2):
-6 937 650 605 005 805 061(10) = 1110 0000 0100 0111 0111 1100 0111 0111 1100 1111 0010 0101 0001 0110 0000 0101
Spaces were used to group digits: for binary, by 4, for decimal, by 3.