What are the required steps to convert base 10 integer
number -7 777 716 553 456 665 864 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:
|-7 777 716 553 456 665 864| = 7 777 716 553 456 665 864
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;
- 7 777 716 553 456 665 864 ÷ 2 = 3 888 858 276 728 332 932 + 0;
- 3 888 858 276 728 332 932 ÷ 2 = 1 944 429 138 364 166 466 + 0;
- 1 944 429 138 364 166 466 ÷ 2 = 972 214 569 182 083 233 + 0;
- 972 214 569 182 083 233 ÷ 2 = 486 107 284 591 041 616 + 1;
- 486 107 284 591 041 616 ÷ 2 = 243 053 642 295 520 808 + 0;
- 243 053 642 295 520 808 ÷ 2 = 121 526 821 147 760 404 + 0;
- 121 526 821 147 760 404 ÷ 2 = 60 763 410 573 880 202 + 0;
- 60 763 410 573 880 202 ÷ 2 = 30 381 705 286 940 101 + 0;
- 30 381 705 286 940 101 ÷ 2 = 15 190 852 643 470 050 + 1;
- 15 190 852 643 470 050 ÷ 2 = 7 595 426 321 735 025 + 0;
- 7 595 426 321 735 025 ÷ 2 = 3 797 713 160 867 512 + 1;
- 3 797 713 160 867 512 ÷ 2 = 1 898 856 580 433 756 + 0;
- 1 898 856 580 433 756 ÷ 2 = 949 428 290 216 878 + 0;
- 949 428 290 216 878 ÷ 2 = 474 714 145 108 439 + 0;
- 474 714 145 108 439 ÷ 2 = 237 357 072 554 219 + 1;
- 237 357 072 554 219 ÷ 2 = 118 678 536 277 109 + 1;
- 118 678 536 277 109 ÷ 2 = 59 339 268 138 554 + 1;
- 59 339 268 138 554 ÷ 2 = 29 669 634 069 277 + 0;
- 29 669 634 069 277 ÷ 2 = 14 834 817 034 638 + 1;
- 14 834 817 034 638 ÷ 2 = 7 417 408 517 319 + 0;
- 7 417 408 517 319 ÷ 2 = 3 708 704 258 659 + 1;
- 3 708 704 258 659 ÷ 2 = 1 854 352 129 329 + 1;
- 1 854 352 129 329 ÷ 2 = 927 176 064 664 + 1;
- 927 176 064 664 ÷ 2 = 463 588 032 332 + 0;
- 463 588 032 332 ÷ 2 = 231 794 016 166 + 0;
- 231 794 016 166 ÷ 2 = 115 897 008 083 + 0;
- 115 897 008 083 ÷ 2 = 57 948 504 041 + 1;
- 57 948 504 041 ÷ 2 = 28 974 252 020 + 1;
- 28 974 252 020 ÷ 2 = 14 487 126 010 + 0;
- 14 487 126 010 ÷ 2 = 7 243 563 005 + 0;
- 7 243 563 005 ÷ 2 = 3 621 781 502 + 1;
- 3 621 781 502 ÷ 2 = 1 810 890 751 + 0;
- 1 810 890 751 ÷ 2 = 905 445 375 + 1;
- 905 445 375 ÷ 2 = 452 722 687 + 1;
- 452 722 687 ÷ 2 = 226 361 343 + 1;
- 226 361 343 ÷ 2 = 113 180 671 + 1;
- 113 180 671 ÷ 2 = 56 590 335 + 1;
- 56 590 335 ÷ 2 = 28 295 167 + 1;
- 28 295 167 ÷ 2 = 14 147 583 + 1;
- 14 147 583 ÷ 2 = 7 073 791 + 1;
- 7 073 791 ÷ 2 = 3 536 895 + 1;
- 3 536 895 ÷ 2 = 1 768 447 + 1;
- 1 768 447 ÷ 2 = 884 223 + 1;
- 884 223 ÷ 2 = 442 111 + 1;
- 442 111 ÷ 2 = 221 055 + 1;
- 221 055 ÷ 2 = 110 527 + 1;
- 110 527 ÷ 2 = 55 263 + 1;
- 55 263 ÷ 2 = 27 631 + 1;
- 27 631 ÷ 2 = 13 815 + 1;
- 13 815 ÷ 2 = 6 907 + 1;
- 6 907 ÷ 2 = 3 453 + 1;
- 3 453 ÷ 2 = 1 726 + 1;
- 1 726 ÷ 2 = 863 + 0;
- 863 ÷ 2 = 431 + 1;
- 431 ÷ 2 = 215 + 1;
- 215 ÷ 2 = 107 + 1;
- 107 ÷ 2 = 53 + 1;
- 53 ÷ 2 = 26 + 1;
- 26 ÷ 2 = 13 + 0;
- 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.
7 777 716 553 456 665 864(10) = 110 1011 1110 1111 1111 1111 1111 1111 0100 1100 0111 0101 1100 0101 0000 1000(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:
7 777 716 553 456 665 864(10) = 0110 1011 1110 1111 1111 1111 1111 1111 0100 1100 0111 0101 1100 0101 0000 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...
-7 777 716 553 456 665 864(10) Base 10 integer number converted and written as a signed binary code (in base 2):
-7 777 716 553 456 665 864(10) = 1110 1011 1110 1111 1111 1111 1111 1111 0100 1100 0111 0101 1100 0101 0000 1000
Spaces were used to group digits: for binary, by 4, for decimal, by 3.