What are the required steps to convert base 10 integer
number -1 283 189 223 323 256 683 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:
|-1 283 189 223 323 256 683| = 1 283 189 223 323 256 683
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;
- 1 283 189 223 323 256 683 ÷ 2 = 641 594 611 661 628 341 + 1;
- 641 594 611 661 628 341 ÷ 2 = 320 797 305 830 814 170 + 1;
- 320 797 305 830 814 170 ÷ 2 = 160 398 652 915 407 085 + 0;
- 160 398 652 915 407 085 ÷ 2 = 80 199 326 457 703 542 + 1;
- 80 199 326 457 703 542 ÷ 2 = 40 099 663 228 851 771 + 0;
- 40 099 663 228 851 771 ÷ 2 = 20 049 831 614 425 885 + 1;
- 20 049 831 614 425 885 ÷ 2 = 10 024 915 807 212 942 + 1;
- 10 024 915 807 212 942 ÷ 2 = 5 012 457 903 606 471 + 0;
- 5 012 457 903 606 471 ÷ 2 = 2 506 228 951 803 235 + 1;
- 2 506 228 951 803 235 ÷ 2 = 1 253 114 475 901 617 + 1;
- 1 253 114 475 901 617 ÷ 2 = 626 557 237 950 808 + 1;
- 626 557 237 950 808 ÷ 2 = 313 278 618 975 404 + 0;
- 313 278 618 975 404 ÷ 2 = 156 639 309 487 702 + 0;
- 156 639 309 487 702 ÷ 2 = 78 319 654 743 851 + 0;
- 78 319 654 743 851 ÷ 2 = 39 159 827 371 925 + 1;
- 39 159 827 371 925 ÷ 2 = 19 579 913 685 962 + 1;
- 19 579 913 685 962 ÷ 2 = 9 789 956 842 981 + 0;
- 9 789 956 842 981 ÷ 2 = 4 894 978 421 490 + 1;
- 4 894 978 421 490 ÷ 2 = 2 447 489 210 745 + 0;
- 2 447 489 210 745 ÷ 2 = 1 223 744 605 372 + 1;
- 1 223 744 605 372 ÷ 2 = 611 872 302 686 + 0;
- 611 872 302 686 ÷ 2 = 305 936 151 343 + 0;
- 305 936 151 343 ÷ 2 = 152 968 075 671 + 1;
- 152 968 075 671 ÷ 2 = 76 484 037 835 + 1;
- 76 484 037 835 ÷ 2 = 38 242 018 917 + 1;
- 38 242 018 917 ÷ 2 = 19 121 009 458 + 1;
- 19 121 009 458 ÷ 2 = 9 560 504 729 + 0;
- 9 560 504 729 ÷ 2 = 4 780 252 364 + 1;
- 4 780 252 364 ÷ 2 = 2 390 126 182 + 0;
- 2 390 126 182 ÷ 2 = 1 195 063 091 + 0;
- 1 195 063 091 ÷ 2 = 597 531 545 + 1;
- 597 531 545 ÷ 2 = 298 765 772 + 1;
- 298 765 772 ÷ 2 = 149 382 886 + 0;
- 149 382 886 ÷ 2 = 74 691 443 + 0;
- 74 691 443 ÷ 2 = 37 345 721 + 1;
- 37 345 721 ÷ 2 = 18 672 860 + 1;
- 18 672 860 ÷ 2 = 9 336 430 + 0;
- 9 336 430 ÷ 2 = 4 668 215 + 0;
- 4 668 215 ÷ 2 = 2 334 107 + 1;
- 2 334 107 ÷ 2 = 1 167 053 + 1;
- 1 167 053 ÷ 2 = 583 526 + 1;
- 583 526 ÷ 2 = 291 763 + 0;
- 291 763 ÷ 2 = 145 881 + 1;
- 145 881 ÷ 2 = 72 940 + 1;
- 72 940 ÷ 2 = 36 470 + 0;
- 36 470 ÷ 2 = 18 235 + 0;
- 18 235 ÷ 2 = 9 117 + 1;
- 9 117 ÷ 2 = 4 558 + 1;
- 4 558 ÷ 2 = 2 279 + 0;
- 2 279 ÷ 2 = 1 139 + 1;
- 1 139 ÷ 2 = 569 + 1;
- 569 ÷ 2 = 284 + 1;
- 284 ÷ 2 = 142 + 0;
- 142 ÷ 2 = 71 + 0;
- 71 ÷ 2 = 35 + 1;
- 35 ÷ 2 = 17 + 1;
- 17 ÷ 2 = 8 + 1;
- 8 ÷ 2 = 4 + 0;
- 4 ÷ 2 = 2 + 0;
- 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.
1 283 189 223 323 256 683(10) = 1 0001 1100 1110 1100 1101 1100 1100 1100 1011 1100 1010 1100 0111 0110 1011(2)
4. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 61.
- 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, 61,
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:
1 283 189 223 323 256 683(10) = 0001 0001 1100 1110 1100 1101 1100 1100 1100 1011 1100 1010 1100 0111 0110 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...
-1 283 189 223 323 256 683(10) Base 10 integer number converted and written as a signed binary code (in base 2):
-1 283 189 223 323 256 683(10) = 1001 0001 1100 1110 1100 1101 1100 1100 1100 1011 1100 1010 1100 0111 0110 1011
Spaces were used to group digits: for binary, by 4, for decimal, by 3.