What are the required steps to convert base 10 integer
number -123 775 873 255 737 592 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:
|-123 775 873 255 737 592| = 123 775 873 255 737 592
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;
- 123 775 873 255 737 592 ÷ 2 = 61 887 936 627 868 796 + 0;
- 61 887 936 627 868 796 ÷ 2 = 30 943 968 313 934 398 + 0;
- 30 943 968 313 934 398 ÷ 2 = 15 471 984 156 967 199 + 0;
- 15 471 984 156 967 199 ÷ 2 = 7 735 992 078 483 599 + 1;
- 7 735 992 078 483 599 ÷ 2 = 3 867 996 039 241 799 + 1;
- 3 867 996 039 241 799 ÷ 2 = 1 933 998 019 620 899 + 1;
- 1 933 998 019 620 899 ÷ 2 = 966 999 009 810 449 + 1;
- 966 999 009 810 449 ÷ 2 = 483 499 504 905 224 + 1;
- 483 499 504 905 224 ÷ 2 = 241 749 752 452 612 + 0;
- 241 749 752 452 612 ÷ 2 = 120 874 876 226 306 + 0;
- 120 874 876 226 306 ÷ 2 = 60 437 438 113 153 + 0;
- 60 437 438 113 153 ÷ 2 = 30 218 719 056 576 + 1;
- 30 218 719 056 576 ÷ 2 = 15 109 359 528 288 + 0;
- 15 109 359 528 288 ÷ 2 = 7 554 679 764 144 + 0;
- 7 554 679 764 144 ÷ 2 = 3 777 339 882 072 + 0;
- 3 777 339 882 072 ÷ 2 = 1 888 669 941 036 + 0;
- 1 888 669 941 036 ÷ 2 = 944 334 970 518 + 0;
- 944 334 970 518 ÷ 2 = 472 167 485 259 + 0;
- 472 167 485 259 ÷ 2 = 236 083 742 629 + 1;
- 236 083 742 629 ÷ 2 = 118 041 871 314 + 1;
- 118 041 871 314 ÷ 2 = 59 020 935 657 + 0;
- 59 020 935 657 ÷ 2 = 29 510 467 828 + 1;
- 29 510 467 828 ÷ 2 = 14 755 233 914 + 0;
- 14 755 233 914 ÷ 2 = 7 377 616 957 + 0;
- 7 377 616 957 ÷ 2 = 3 688 808 478 + 1;
- 3 688 808 478 ÷ 2 = 1 844 404 239 + 0;
- 1 844 404 239 ÷ 2 = 922 202 119 + 1;
- 922 202 119 ÷ 2 = 461 101 059 + 1;
- 461 101 059 ÷ 2 = 230 550 529 + 1;
- 230 550 529 ÷ 2 = 115 275 264 + 1;
- 115 275 264 ÷ 2 = 57 637 632 + 0;
- 57 637 632 ÷ 2 = 28 818 816 + 0;
- 28 818 816 ÷ 2 = 14 409 408 + 0;
- 14 409 408 ÷ 2 = 7 204 704 + 0;
- 7 204 704 ÷ 2 = 3 602 352 + 0;
- 3 602 352 ÷ 2 = 1 801 176 + 0;
- 1 801 176 ÷ 2 = 900 588 + 0;
- 900 588 ÷ 2 = 450 294 + 0;
- 450 294 ÷ 2 = 225 147 + 0;
- 225 147 ÷ 2 = 112 573 + 1;
- 112 573 ÷ 2 = 56 286 + 1;
- 56 286 ÷ 2 = 28 143 + 0;
- 28 143 ÷ 2 = 14 071 + 1;
- 14 071 ÷ 2 = 7 035 + 1;
- 7 035 ÷ 2 = 3 517 + 1;
- 3 517 ÷ 2 = 1 758 + 1;
- 1 758 ÷ 2 = 879 + 0;
- 879 ÷ 2 = 439 + 1;
- 439 ÷ 2 = 219 + 1;
- 219 ÷ 2 = 109 + 1;
- 109 ÷ 2 = 54 + 1;
- 54 ÷ 2 = 27 + 0;
- 27 ÷ 2 = 13 + 1;
- 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.
123 775 873 255 737 592(10) = 1 1011 0111 1011 1101 1000 0000 0011 1101 0010 1100 0000 1000 1111 1000(2)
4. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 57.
- 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, 57,
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:
123 775 873 255 737 592(10) = 0000 0001 1011 0111 1011 1101 1000 0000 0011 1101 0010 1100 0000 1000 1111 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...
-123 775 873 255 737 592(10) Base 10 integer number converted and written as a signed binary code (in base 2):
-123 775 873 255 737 592(10) = 1000 0001 1011 0111 1011 1101 1000 0000 0011 1101 0010 1100 0000 1000 1111 1000
Spaces were used to group digits: for binary, by 4, for decimal, by 3.