What are the required steps to convert base 10 integer
number -6 196 495 686 129 627 913 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 196 495 686 129 627 913| = 6 196 495 686 129 627 913
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 196 495 686 129 627 913 ÷ 2 = 3 098 247 843 064 813 956 + 1;
- 3 098 247 843 064 813 956 ÷ 2 = 1 549 123 921 532 406 978 + 0;
- 1 549 123 921 532 406 978 ÷ 2 = 774 561 960 766 203 489 + 0;
- 774 561 960 766 203 489 ÷ 2 = 387 280 980 383 101 744 + 1;
- 387 280 980 383 101 744 ÷ 2 = 193 640 490 191 550 872 + 0;
- 193 640 490 191 550 872 ÷ 2 = 96 820 245 095 775 436 + 0;
- 96 820 245 095 775 436 ÷ 2 = 48 410 122 547 887 718 + 0;
- 48 410 122 547 887 718 ÷ 2 = 24 205 061 273 943 859 + 0;
- 24 205 061 273 943 859 ÷ 2 = 12 102 530 636 971 929 + 1;
- 12 102 530 636 971 929 ÷ 2 = 6 051 265 318 485 964 + 1;
- 6 051 265 318 485 964 ÷ 2 = 3 025 632 659 242 982 + 0;
- 3 025 632 659 242 982 ÷ 2 = 1 512 816 329 621 491 + 0;
- 1 512 816 329 621 491 ÷ 2 = 756 408 164 810 745 + 1;
- 756 408 164 810 745 ÷ 2 = 378 204 082 405 372 + 1;
- 378 204 082 405 372 ÷ 2 = 189 102 041 202 686 + 0;
- 189 102 041 202 686 ÷ 2 = 94 551 020 601 343 + 0;
- 94 551 020 601 343 ÷ 2 = 47 275 510 300 671 + 1;
- 47 275 510 300 671 ÷ 2 = 23 637 755 150 335 + 1;
- 23 637 755 150 335 ÷ 2 = 11 818 877 575 167 + 1;
- 11 818 877 575 167 ÷ 2 = 5 909 438 787 583 + 1;
- 5 909 438 787 583 ÷ 2 = 2 954 719 393 791 + 1;
- 2 954 719 393 791 ÷ 2 = 1 477 359 696 895 + 1;
- 1 477 359 696 895 ÷ 2 = 738 679 848 447 + 1;
- 738 679 848 447 ÷ 2 = 369 339 924 223 + 1;
- 369 339 924 223 ÷ 2 = 184 669 962 111 + 1;
- 184 669 962 111 ÷ 2 = 92 334 981 055 + 1;
- 92 334 981 055 ÷ 2 = 46 167 490 527 + 1;
- 46 167 490 527 ÷ 2 = 23 083 745 263 + 1;
- 23 083 745 263 ÷ 2 = 11 541 872 631 + 1;
- 11 541 872 631 ÷ 2 = 5 770 936 315 + 1;
- 5 770 936 315 ÷ 2 = 2 885 468 157 + 1;
- 2 885 468 157 ÷ 2 = 1 442 734 078 + 1;
- 1 442 734 078 ÷ 2 = 721 367 039 + 0;
- 721 367 039 ÷ 2 = 360 683 519 + 1;
- 360 683 519 ÷ 2 = 180 341 759 + 1;
- 180 341 759 ÷ 2 = 90 170 879 + 1;
- 90 170 879 ÷ 2 = 45 085 439 + 1;
- 45 085 439 ÷ 2 = 22 542 719 + 1;
- 22 542 719 ÷ 2 = 11 271 359 + 1;
- 11 271 359 ÷ 2 = 5 635 679 + 1;
- 5 635 679 ÷ 2 = 2 817 839 + 1;
- 2 817 839 ÷ 2 = 1 408 919 + 1;
- 1 408 919 ÷ 2 = 704 459 + 1;
- 704 459 ÷ 2 = 352 229 + 1;
- 352 229 ÷ 2 = 176 114 + 1;
- 176 114 ÷ 2 = 88 057 + 0;
- 88 057 ÷ 2 = 44 028 + 1;
- 44 028 ÷ 2 = 22 014 + 0;
- 22 014 ÷ 2 = 11 007 + 0;
- 11 007 ÷ 2 = 5 503 + 1;
- 5 503 ÷ 2 = 2 751 + 1;
- 2 751 ÷ 2 = 1 375 + 1;
- 1 375 ÷ 2 = 687 + 1;
- 687 ÷ 2 = 343 + 1;
- 343 ÷ 2 = 171 + 1;
- 171 ÷ 2 = 85 + 1;
- 85 ÷ 2 = 42 + 1;
- 42 ÷ 2 = 21 + 0;
- 21 ÷ 2 = 10 + 1;
- 10 ÷ 2 = 5 + 0;
- 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 196 495 686 129 627 913(10) = 101 0101 1111 1110 0101 1111 1111 1110 1111 1111 1111 1111 0011 0011 0000 1001(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 196 495 686 129 627 913(10) = 0101 0101 1111 1110 0101 1111 1111 1110 1111 1111 1111 1111 0011 0011 0000 1001
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 196 495 686 129 627 913(10) Base 10 integer number converted and written as a signed binary code (in base 2):
-6 196 495 686 129 627 913(10) = 1101 0101 1111 1110 0101 1111 1111 1110 1111 1111 1111 1111 0011 0011 0000 1001
Spaces were used to group digits: for binary, by 4, for decimal, by 3.