What are the required steps to convert base 10 integer
number -36 170 086 410 616 699 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:
|-36 170 086 410 616 699| = 36 170 086 410 616 699
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;
- 36 170 086 410 616 699 ÷ 2 = 18 085 043 205 308 349 + 1;
- 18 085 043 205 308 349 ÷ 2 = 9 042 521 602 654 174 + 1;
- 9 042 521 602 654 174 ÷ 2 = 4 521 260 801 327 087 + 0;
- 4 521 260 801 327 087 ÷ 2 = 2 260 630 400 663 543 + 1;
- 2 260 630 400 663 543 ÷ 2 = 1 130 315 200 331 771 + 1;
- 1 130 315 200 331 771 ÷ 2 = 565 157 600 165 885 + 1;
- 565 157 600 165 885 ÷ 2 = 282 578 800 082 942 + 1;
- 282 578 800 082 942 ÷ 2 = 141 289 400 041 471 + 0;
- 141 289 400 041 471 ÷ 2 = 70 644 700 020 735 + 1;
- 70 644 700 020 735 ÷ 2 = 35 322 350 010 367 + 1;
- 35 322 350 010 367 ÷ 2 = 17 661 175 005 183 + 1;
- 17 661 175 005 183 ÷ 2 = 8 830 587 502 591 + 1;
- 8 830 587 502 591 ÷ 2 = 4 415 293 751 295 + 1;
- 4 415 293 751 295 ÷ 2 = 2 207 646 875 647 + 1;
- 2 207 646 875 647 ÷ 2 = 1 103 823 437 823 + 1;
- 1 103 823 437 823 ÷ 2 = 551 911 718 911 + 1;
- 551 911 718 911 ÷ 2 = 275 955 859 455 + 1;
- 275 955 859 455 ÷ 2 = 137 977 929 727 + 1;
- 137 977 929 727 ÷ 2 = 68 988 964 863 + 1;
- 68 988 964 863 ÷ 2 = 34 494 482 431 + 1;
- 34 494 482 431 ÷ 2 = 17 247 241 215 + 1;
- 17 247 241 215 ÷ 2 = 8 623 620 607 + 1;
- 8 623 620 607 ÷ 2 = 4 311 810 303 + 1;
- 4 311 810 303 ÷ 2 = 2 155 905 151 + 1;
- 2 155 905 151 ÷ 2 = 1 077 952 575 + 1;
- 1 077 952 575 ÷ 2 = 538 976 287 + 1;
- 538 976 287 ÷ 2 = 269 488 143 + 1;
- 269 488 143 ÷ 2 = 134 744 071 + 1;
- 134 744 071 ÷ 2 = 67 372 035 + 1;
- 67 372 035 ÷ 2 = 33 686 017 + 1;
- 33 686 017 ÷ 2 = 16 843 008 + 1;
- 16 843 008 ÷ 2 = 8 421 504 + 0;
- 8 421 504 ÷ 2 = 4 210 752 + 0;
- 4 210 752 ÷ 2 = 2 105 376 + 0;
- 2 105 376 ÷ 2 = 1 052 688 + 0;
- 1 052 688 ÷ 2 = 526 344 + 0;
- 526 344 ÷ 2 = 263 172 + 0;
- 263 172 ÷ 2 = 131 586 + 0;
- 131 586 ÷ 2 = 65 793 + 0;
- 65 793 ÷ 2 = 32 896 + 1;
- 32 896 ÷ 2 = 16 448 + 0;
- 16 448 ÷ 2 = 8 224 + 0;
- 8 224 ÷ 2 = 4 112 + 0;
- 4 112 ÷ 2 = 2 056 + 0;
- 2 056 ÷ 2 = 1 028 + 0;
- 1 028 ÷ 2 = 514 + 0;
- 514 ÷ 2 = 257 + 0;
- 257 ÷ 2 = 128 + 1;
- 128 ÷ 2 = 64 + 0;
- 64 ÷ 2 = 32 + 0;
- 32 ÷ 2 = 16 + 0;
- 16 ÷ 2 = 8 + 0;
- 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.
36 170 086 410 616 699(10) = 1000 0000 1000 0000 1000 0000 0111 1111 1111 1111 1111 1111 0111 1011(2)
4. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 56.
- 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, 56,
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:
36 170 086 410 616 699(10) = 0000 0000 1000 0000 1000 0000 1000 0000 0111 1111 1111 1111 1111 1111 0111 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...
-36 170 086 410 616 699(10) Base 10 integer number converted and written as a signed binary code (in base 2):
-36 170 086 410 616 699(10) = 1000 0000 1000 0000 1000 0000 1000 0000 0111 1111 1111 1111 1111 1111 0111 1011
Spaces were used to group digits: for binary, by 4, for decimal, by 3.