What are the required steps to convert base 10 integer
number -1 336 147 191 563 544 666 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 336 147 191 563 544 666| = 1 336 147 191 563 544 666
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 336 147 191 563 544 666 ÷ 2 = 668 073 595 781 772 333 + 0;
- 668 073 595 781 772 333 ÷ 2 = 334 036 797 890 886 166 + 1;
- 334 036 797 890 886 166 ÷ 2 = 167 018 398 945 443 083 + 0;
- 167 018 398 945 443 083 ÷ 2 = 83 509 199 472 721 541 + 1;
- 83 509 199 472 721 541 ÷ 2 = 41 754 599 736 360 770 + 1;
- 41 754 599 736 360 770 ÷ 2 = 20 877 299 868 180 385 + 0;
- 20 877 299 868 180 385 ÷ 2 = 10 438 649 934 090 192 + 1;
- 10 438 649 934 090 192 ÷ 2 = 5 219 324 967 045 096 + 0;
- 5 219 324 967 045 096 ÷ 2 = 2 609 662 483 522 548 + 0;
- 2 609 662 483 522 548 ÷ 2 = 1 304 831 241 761 274 + 0;
- 1 304 831 241 761 274 ÷ 2 = 652 415 620 880 637 + 0;
- 652 415 620 880 637 ÷ 2 = 326 207 810 440 318 + 1;
- 326 207 810 440 318 ÷ 2 = 163 103 905 220 159 + 0;
- 163 103 905 220 159 ÷ 2 = 81 551 952 610 079 + 1;
- 81 551 952 610 079 ÷ 2 = 40 775 976 305 039 + 1;
- 40 775 976 305 039 ÷ 2 = 20 387 988 152 519 + 1;
- 20 387 988 152 519 ÷ 2 = 10 193 994 076 259 + 1;
- 10 193 994 076 259 ÷ 2 = 5 096 997 038 129 + 1;
- 5 096 997 038 129 ÷ 2 = 2 548 498 519 064 + 1;
- 2 548 498 519 064 ÷ 2 = 1 274 249 259 532 + 0;
- 1 274 249 259 532 ÷ 2 = 637 124 629 766 + 0;
- 637 124 629 766 ÷ 2 = 318 562 314 883 + 0;
- 318 562 314 883 ÷ 2 = 159 281 157 441 + 1;
- 159 281 157 441 ÷ 2 = 79 640 578 720 + 1;
- 79 640 578 720 ÷ 2 = 39 820 289 360 + 0;
- 39 820 289 360 ÷ 2 = 19 910 144 680 + 0;
- 19 910 144 680 ÷ 2 = 9 955 072 340 + 0;
- 9 955 072 340 ÷ 2 = 4 977 536 170 + 0;
- 4 977 536 170 ÷ 2 = 2 488 768 085 + 0;
- 2 488 768 085 ÷ 2 = 1 244 384 042 + 1;
- 1 244 384 042 ÷ 2 = 622 192 021 + 0;
- 622 192 021 ÷ 2 = 311 096 010 + 1;
- 311 096 010 ÷ 2 = 155 548 005 + 0;
- 155 548 005 ÷ 2 = 77 774 002 + 1;
- 77 774 002 ÷ 2 = 38 887 001 + 0;
- 38 887 001 ÷ 2 = 19 443 500 + 1;
- 19 443 500 ÷ 2 = 9 721 750 + 0;
- 9 721 750 ÷ 2 = 4 860 875 + 0;
- 4 860 875 ÷ 2 = 2 430 437 + 1;
- 2 430 437 ÷ 2 = 1 215 218 + 1;
- 1 215 218 ÷ 2 = 607 609 + 0;
- 607 609 ÷ 2 = 303 804 + 1;
- 303 804 ÷ 2 = 151 902 + 0;
- 151 902 ÷ 2 = 75 951 + 0;
- 75 951 ÷ 2 = 37 975 + 1;
- 37 975 ÷ 2 = 18 987 + 1;
- 18 987 ÷ 2 = 9 493 + 1;
- 9 493 ÷ 2 = 4 746 + 1;
- 4 746 ÷ 2 = 2 373 + 0;
- 2 373 ÷ 2 = 1 186 + 1;
- 1 186 ÷ 2 = 593 + 0;
- 593 ÷ 2 = 296 + 1;
- 296 ÷ 2 = 148 + 0;
- 148 ÷ 2 = 74 + 0;
- 74 ÷ 2 = 37 + 0;
- 37 ÷ 2 = 18 + 1;
- 18 ÷ 2 = 9 + 0;
- 9 ÷ 2 = 4 + 1;
- 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 336 147 191 563 544 666(10) = 1 0010 1000 1010 1111 0010 1100 1010 1010 0000 1100 0111 1110 1000 0101 1010(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 336 147 191 563 544 666(10) = 0001 0010 1000 1010 1111 0010 1100 1010 1010 0000 1100 0111 1110 1000 0101 1010
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 336 147 191 563 544 666(10) Base 10 integer number converted and written as a signed binary code (in base 2):
-1 336 147 191 563 544 666(10) = 1001 0010 1000 1010 1111 0010 1100 1010 1010 0000 1100 0111 1110 1000 0101 1010
Spaces were used to group digits: for binary, by 4, for decimal, by 3.