What are the required steps to convert base 10 integer
number -4 577 968 356 947 112 905 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:
|-4 577 968 356 947 112 905| = 4 577 968 356 947 112 905
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;
- 4 577 968 356 947 112 905 ÷ 2 = 2 288 984 178 473 556 452 + 1;
- 2 288 984 178 473 556 452 ÷ 2 = 1 144 492 089 236 778 226 + 0;
- 1 144 492 089 236 778 226 ÷ 2 = 572 246 044 618 389 113 + 0;
- 572 246 044 618 389 113 ÷ 2 = 286 123 022 309 194 556 + 1;
- 286 123 022 309 194 556 ÷ 2 = 143 061 511 154 597 278 + 0;
- 143 061 511 154 597 278 ÷ 2 = 71 530 755 577 298 639 + 0;
- 71 530 755 577 298 639 ÷ 2 = 35 765 377 788 649 319 + 1;
- 35 765 377 788 649 319 ÷ 2 = 17 882 688 894 324 659 + 1;
- 17 882 688 894 324 659 ÷ 2 = 8 941 344 447 162 329 + 1;
- 8 941 344 447 162 329 ÷ 2 = 4 470 672 223 581 164 + 1;
- 4 470 672 223 581 164 ÷ 2 = 2 235 336 111 790 582 + 0;
- 2 235 336 111 790 582 ÷ 2 = 1 117 668 055 895 291 + 0;
- 1 117 668 055 895 291 ÷ 2 = 558 834 027 947 645 + 1;
- 558 834 027 947 645 ÷ 2 = 279 417 013 973 822 + 1;
- 279 417 013 973 822 ÷ 2 = 139 708 506 986 911 + 0;
- 139 708 506 986 911 ÷ 2 = 69 854 253 493 455 + 1;
- 69 854 253 493 455 ÷ 2 = 34 927 126 746 727 + 1;
- 34 927 126 746 727 ÷ 2 = 17 463 563 373 363 + 1;
- 17 463 563 373 363 ÷ 2 = 8 731 781 686 681 + 1;
- 8 731 781 686 681 ÷ 2 = 4 365 890 843 340 + 1;
- 4 365 890 843 340 ÷ 2 = 2 182 945 421 670 + 0;
- 2 182 945 421 670 ÷ 2 = 1 091 472 710 835 + 0;
- 1 091 472 710 835 ÷ 2 = 545 736 355 417 + 1;
- 545 736 355 417 ÷ 2 = 272 868 177 708 + 1;
- 272 868 177 708 ÷ 2 = 136 434 088 854 + 0;
- 136 434 088 854 ÷ 2 = 68 217 044 427 + 0;
- 68 217 044 427 ÷ 2 = 34 108 522 213 + 1;
- 34 108 522 213 ÷ 2 = 17 054 261 106 + 1;
- 17 054 261 106 ÷ 2 = 8 527 130 553 + 0;
- 8 527 130 553 ÷ 2 = 4 263 565 276 + 1;
- 4 263 565 276 ÷ 2 = 2 131 782 638 + 0;
- 2 131 782 638 ÷ 2 = 1 065 891 319 + 0;
- 1 065 891 319 ÷ 2 = 532 945 659 + 1;
- 532 945 659 ÷ 2 = 266 472 829 + 1;
- 266 472 829 ÷ 2 = 133 236 414 + 1;
- 133 236 414 ÷ 2 = 66 618 207 + 0;
- 66 618 207 ÷ 2 = 33 309 103 + 1;
- 33 309 103 ÷ 2 = 16 654 551 + 1;
- 16 654 551 ÷ 2 = 8 327 275 + 1;
- 8 327 275 ÷ 2 = 4 163 637 + 1;
- 4 163 637 ÷ 2 = 2 081 818 + 1;
- 2 081 818 ÷ 2 = 1 040 909 + 0;
- 1 040 909 ÷ 2 = 520 454 + 1;
- 520 454 ÷ 2 = 260 227 + 0;
- 260 227 ÷ 2 = 130 113 + 1;
- 130 113 ÷ 2 = 65 056 + 1;
- 65 056 ÷ 2 = 32 528 + 0;
- 32 528 ÷ 2 = 16 264 + 0;
- 16 264 ÷ 2 = 8 132 + 0;
- 8 132 ÷ 2 = 4 066 + 0;
- 4 066 ÷ 2 = 2 033 + 0;
- 2 033 ÷ 2 = 1 016 + 1;
- 1 016 ÷ 2 = 508 + 0;
- 508 ÷ 2 = 254 + 0;
- 254 ÷ 2 = 127 + 0;
- 127 ÷ 2 = 63 + 1;
- 63 ÷ 2 = 31 + 1;
- 31 ÷ 2 = 15 + 1;
- 15 ÷ 2 = 7 + 1;
- 7 ÷ 2 = 3 + 1;
- 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.
4 577 968 356 947 112 905(10) = 11 1111 1000 1000 0011 0101 1111 0111 0010 1100 1100 1111 1011 0011 1100 1001(2)
4. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 62.
- 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, 62,
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:
4 577 968 356 947 112 905(10) = 0011 1111 1000 1000 0011 0101 1111 0111 0010 1100 1100 1111 1011 0011 1100 1001
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...
-4 577 968 356 947 112 905(10) Base 10 integer number converted and written as a signed binary code (in base 2):
-4 577 968 356 947 112 905(10) = 1011 1111 1000 1000 0011 0101 1111 0111 0010 1100 1100 1111 1011 0011 1100 1001
Spaces were used to group digits: for binary, by 4, for decimal, by 3.