What are the required steps to convert base 10 integer
number -7 541 871 867 692 106 840 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:
|-7 541 871 867 692 106 840| = 7 541 871 867 692 106 840
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;
- 7 541 871 867 692 106 840 ÷ 2 = 3 770 935 933 846 053 420 + 0;
- 3 770 935 933 846 053 420 ÷ 2 = 1 885 467 966 923 026 710 + 0;
- 1 885 467 966 923 026 710 ÷ 2 = 942 733 983 461 513 355 + 0;
- 942 733 983 461 513 355 ÷ 2 = 471 366 991 730 756 677 + 1;
- 471 366 991 730 756 677 ÷ 2 = 235 683 495 865 378 338 + 1;
- 235 683 495 865 378 338 ÷ 2 = 117 841 747 932 689 169 + 0;
- 117 841 747 932 689 169 ÷ 2 = 58 920 873 966 344 584 + 1;
- 58 920 873 966 344 584 ÷ 2 = 29 460 436 983 172 292 + 0;
- 29 460 436 983 172 292 ÷ 2 = 14 730 218 491 586 146 + 0;
- 14 730 218 491 586 146 ÷ 2 = 7 365 109 245 793 073 + 0;
- 7 365 109 245 793 073 ÷ 2 = 3 682 554 622 896 536 + 1;
- 3 682 554 622 896 536 ÷ 2 = 1 841 277 311 448 268 + 0;
- 1 841 277 311 448 268 ÷ 2 = 920 638 655 724 134 + 0;
- 920 638 655 724 134 ÷ 2 = 460 319 327 862 067 + 0;
- 460 319 327 862 067 ÷ 2 = 230 159 663 931 033 + 1;
- 230 159 663 931 033 ÷ 2 = 115 079 831 965 516 + 1;
- 115 079 831 965 516 ÷ 2 = 57 539 915 982 758 + 0;
- 57 539 915 982 758 ÷ 2 = 28 769 957 991 379 + 0;
- 28 769 957 991 379 ÷ 2 = 14 384 978 995 689 + 1;
- 14 384 978 995 689 ÷ 2 = 7 192 489 497 844 + 1;
- 7 192 489 497 844 ÷ 2 = 3 596 244 748 922 + 0;
- 3 596 244 748 922 ÷ 2 = 1 798 122 374 461 + 0;
- 1 798 122 374 461 ÷ 2 = 899 061 187 230 + 1;
- 899 061 187 230 ÷ 2 = 449 530 593 615 + 0;
- 449 530 593 615 ÷ 2 = 224 765 296 807 + 1;
- 224 765 296 807 ÷ 2 = 112 382 648 403 + 1;
- 112 382 648 403 ÷ 2 = 56 191 324 201 + 1;
- 56 191 324 201 ÷ 2 = 28 095 662 100 + 1;
- 28 095 662 100 ÷ 2 = 14 047 831 050 + 0;
- 14 047 831 050 ÷ 2 = 7 023 915 525 + 0;
- 7 023 915 525 ÷ 2 = 3 511 957 762 + 1;
- 3 511 957 762 ÷ 2 = 1 755 978 881 + 0;
- 1 755 978 881 ÷ 2 = 877 989 440 + 1;
- 877 989 440 ÷ 2 = 438 994 720 + 0;
- 438 994 720 ÷ 2 = 219 497 360 + 0;
- 219 497 360 ÷ 2 = 109 748 680 + 0;
- 109 748 680 ÷ 2 = 54 874 340 + 0;
- 54 874 340 ÷ 2 = 27 437 170 + 0;
- 27 437 170 ÷ 2 = 13 718 585 + 0;
- 13 718 585 ÷ 2 = 6 859 292 + 1;
- 6 859 292 ÷ 2 = 3 429 646 + 0;
- 3 429 646 ÷ 2 = 1 714 823 + 0;
- 1 714 823 ÷ 2 = 857 411 + 1;
- 857 411 ÷ 2 = 428 705 + 1;
- 428 705 ÷ 2 = 214 352 + 1;
- 214 352 ÷ 2 = 107 176 + 0;
- 107 176 ÷ 2 = 53 588 + 0;
- 53 588 ÷ 2 = 26 794 + 0;
- 26 794 ÷ 2 = 13 397 + 0;
- 13 397 ÷ 2 = 6 698 + 1;
- 6 698 ÷ 2 = 3 349 + 0;
- 3 349 ÷ 2 = 1 674 + 1;
- 1 674 ÷ 2 = 837 + 0;
- 837 ÷ 2 = 418 + 1;
- 418 ÷ 2 = 209 + 0;
- 209 ÷ 2 = 104 + 1;
- 104 ÷ 2 = 52 + 0;
- 52 ÷ 2 = 26 + 0;
- 26 ÷ 2 = 13 + 0;
- 13 ÷ 2 = 6 + 1;
- 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.
7 541 871 867 692 106 840(10) = 110 1000 1010 1010 0001 1100 1000 0001 0100 1111 0100 1100 1100 0100 0101 1000(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:
7 541 871 867 692 106 840(10) = 0110 1000 1010 1010 0001 1100 1000 0001 0100 1111 0100 1100 1100 0100 0101 1000
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...
-7 541 871 867 692 106 840(10) Base 10 integer number converted and written as a signed binary code (in base 2):
-7 541 871 867 692 106 840(10) = 1110 1000 1010 1010 0001 1100 1000 0001 0100 1111 0100 1100 1100 0100 0101 1000
Spaces were used to group digits: for binary, by 4, for decimal, by 3.