What are the required steps to convert base 10 integer
number -95 225 469 143 005 606 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:
|-95 225 469 143 005 606| = 95 225 469 143 005 606
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;
- 95 225 469 143 005 606 ÷ 2 = 47 612 734 571 502 803 + 0;
- 47 612 734 571 502 803 ÷ 2 = 23 806 367 285 751 401 + 1;
- 23 806 367 285 751 401 ÷ 2 = 11 903 183 642 875 700 + 1;
- 11 903 183 642 875 700 ÷ 2 = 5 951 591 821 437 850 + 0;
- 5 951 591 821 437 850 ÷ 2 = 2 975 795 910 718 925 + 0;
- 2 975 795 910 718 925 ÷ 2 = 1 487 897 955 359 462 + 1;
- 1 487 897 955 359 462 ÷ 2 = 743 948 977 679 731 + 0;
- 743 948 977 679 731 ÷ 2 = 371 974 488 839 865 + 1;
- 371 974 488 839 865 ÷ 2 = 185 987 244 419 932 + 1;
- 185 987 244 419 932 ÷ 2 = 92 993 622 209 966 + 0;
- 92 993 622 209 966 ÷ 2 = 46 496 811 104 983 + 0;
- 46 496 811 104 983 ÷ 2 = 23 248 405 552 491 + 1;
- 23 248 405 552 491 ÷ 2 = 11 624 202 776 245 + 1;
- 11 624 202 776 245 ÷ 2 = 5 812 101 388 122 + 1;
- 5 812 101 388 122 ÷ 2 = 2 906 050 694 061 + 0;
- 2 906 050 694 061 ÷ 2 = 1 453 025 347 030 + 1;
- 1 453 025 347 030 ÷ 2 = 726 512 673 515 + 0;
- 726 512 673 515 ÷ 2 = 363 256 336 757 + 1;
- 363 256 336 757 ÷ 2 = 181 628 168 378 + 1;
- 181 628 168 378 ÷ 2 = 90 814 084 189 + 0;
- 90 814 084 189 ÷ 2 = 45 407 042 094 + 1;
- 45 407 042 094 ÷ 2 = 22 703 521 047 + 0;
- 22 703 521 047 ÷ 2 = 11 351 760 523 + 1;
- 11 351 760 523 ÷ 2 = 5 675 880 261 + 1;
- 5 675 880 261 ÷ 2 = 2 837 940 130 + 1;
- 2 837 940 130 ÷ 2 = 1 418 970 065 + 0;
- 1 418 970 065 ÷ 2 = 709 485 032 + 1;
- 709 485 032 ÷ 2 = 354 742 516 + 0;
- 354 742 516 ÷ 2 = 177 371 258 + 0;
- 177 371 258 ÷ 2 = 88 685 629 + 0;
- 88 685 629 ÷ 2 = 44 342 814 + 1;
- 44 342 814 ÷ 2 = 22 171 407 + 0;
- 22 171 407 ÷ 2 = 11 085 703 + 1;
- 11 085 703 ÷ 2 = 5 542 851 + 1;
- 5 542 851 ÷ 2 = 2 771 425 + 1;
- 2 771 425 ÷ 2 = 1 385 712 + 1;
- 1 385 712 ÷ 2 = 692 856 + 0;
- 692 856 ÷ 2 = 346 428 + 0;
- 346 428 ÷ 2 = 173 214 + 0;
- 173 214 ÷ 2 = 86 607 + 0;
- 86 607 ÷ 2 = 43 303 + 1;
- 43 303 ÷ 2 = 21 651 + 1;
- 21 651 ÷ 2 = 10 825 + 1;
- 10 825 ÷ 2 = 5 412 + 1;
- 5 412 ÷ 2 = 2 706 + 0;
- 2 706 ÷ 2 = 1 353 + 0;
- 1 353 ÷ 2 = 676 + 1;
- 676 ÷ 2 = 338 + 0;
- 338 ÷ 2 = 169 + 0;
- 169 ÷ 2 = 84 + 1;
- 84 ÷ 2 = 42 + 0;
- 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.
95 225 469 143 005 606(10) = 1 0101 0010 0100 1111 0000 1111 0100 0101 1101 0110 1011 1001 1010 0110(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:
95 225 469 143 005 606(10) = 0000 0001 0101 0010 0100 1111 0000 1111 0100 0101 1101 0110 1011 1001 1010 0110
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...
-95 225 469 143 005 606(10) Base 10 integer number converted and written as a signed binary code (in base 2):
-95 225 469 143 005 606(10) = 1000 0001 0101 0010 0100 1111 0000 1111 0100 0101 1101 0110 1011 1001 1010 0110
Spaces were used to group digits: for binary, by 4, for decimal, by 3.