What are the required steps to convert base 10 integer
number -4 408 533 913 893 198 798 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 408 533 913 893 198 798| = 4 408 533 913 893 198 798
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 408 533 913 893 198 798 ÷ 2 = 2 204 266 956 946 599 399 + 0;
- 2 204 266 956 946 599 399 ÷ 2 = 1 102 133 478 473 299 699 + 1;
- 1 102 133 478 473 299 699 ÷ 2 = 551 066 739 236 649 849 + 1;
- 551 066 739 236 649 849 ÷ 2 = 275 533 369 618 324 924 + 1;
- 275 533 369 618 324 924 ÷ 2 = 137 766 684 809 162 462 + 0;
- 137 766 684 809 162 462 ÷ 2 = 68 883 342 404 581 231 + 0;
- 68 883 342 404 581 231 ÷ 2 = 34 441 671 202 290 615 + 1;
- 34 441 671 202 290 615 ÷ 2 = 17 220 835 601 145 307 + 1;
- 17 220 835 601 145 307 ÷ 2 = 8 610 417 800 572 653 + 1;
- 8 610 417 800 572 653 ÷ 2 = 4 305 208 900 286 326 + 1;
- 4 305 208 900 286 326 ÷ 2 = 2 152 604 450 143 163 + 0;
- 2 152 604 450 143 163 ÷ 2 = 1 076 302 225 071 581 + 1;
- 1 076 302 225 071 581 ÷ 2 = 538 151 112 535 790 + 1;
- 538 151 112 535 790 ÷ 2 = 269 075 556 267 895 + 0;
- 269 075 556 267 895 ÷ 2 = 134 537 778 133 947 + 1;
- 134 537 778 133 947 ÷ 2 = 67 268 889 066 973 + 1;
- 67 268 889 066 973 ÷ 2 = 33 634 444 533 486 + 1;
- 33 634 444 533 486 ÷ 2 = 16 817 222 266 743 + 0;
- 16 817 222 266 743 ÷ 2 = 8 408 611 133 371 + 1;
- 8 408 611 133 371 ÷ 2 = 4 204 305 566 685 + 1;
- 4 204 305 566 685 ÷ 2 = 2 102 152 783 342 + 1;
- 2 102 152 783 342 ÷ 2 = 1 051 076 391 671 + 0;
- 1 051 076 391 671 ÷ 2 = 525 538 195 835 + 1;
- 525 538 195 835 ÷ 2 = 262 769 097 917 + 1;
- 262 769 097 917 ÷ 2 = 131 384 548 958 + 1;
- 131 384 548 958 ÷ 2 = 65 692 274 479 + 0;
- 65 692 274 479 ÷ 2 = 32 846 137 239 + 1;
- 32 846 137 239 ÷ 2 = 16 423 068 619 + 1;
- 16 423 068 619 ÷ 2 = 8 211 534 309 + 1;
- 8 211 534 309 ÷ 2 = 4 105 767 154 + 1;
- 4 105 767 154 ÷ 2 = 2 052 883 577 + 0;
- 2 052 883 577 ÷ 2 = 1 026 441 788 + 1;
- 1 026 441 788 ÷ 2 = 513 220 894 + 0;
- 513 220 894 ÷ 2 = 256 610 447 + 0;
- 256 610 447 ÷ 2 = 128 305 223 + 1;
- 128 305 223 ÷ 2 = 64 152 611 + 1;
- 64 152 611 ÷ 2 = 32 076 305 + 1;
- 32 076 305 ÷ 2 = 16 038 152 + 1;
- 16 038 152 ÷ 2 = 8 019 076 + 0;
- 8 019 076 ÷ 2 = 4 009 538 + 0;
- 4 009 538 ÷ 2 = 2 004 769 + 0;
- 2 004 769 ÷ 2 = 1 002 384 + 1;
- 1 002 384 ÷ 2 = 501 192 + 0;
- 501 192 ÷ 2 = 250 596 + 0;
- 250 596 ÷ 2 = 125 298 + 0;
- 125 298 ÷ 2 = 62 649 + 0;
- 62 649 ÷ 2 = 31 324 + 1;
- 31 324 ÷ 2 = 15 662 + 0;
- 15 662 ÷ 2 = 7 831 + 0;
- 7 831 ÷ 2 = 3 915 + 1;
- 3 915 ÷ 2 = 1 957 + 1;
- 1 957 ÷ 2 = 978 + 1;
- 978 ÷ 2 = 489 + 0;
- 489 ÷ 2 = 244 + 1;
- 244 ÷ 2 = 122 + 0;
- 122 ÷ 2 = 61 + 0;
- 61 ÷ 2 = 30 + 1;
- 30 ÷ 2 = 15 + 0;
- 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 408 533 913 893 198 798(10) = 11 1101 0010 1110 0100 0010 0011 1100 1011 1101 1101 1101 1101 1011 1100 1110(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 408 533 913 893 198 798(10) = 0011 1101 0010 1110 0100 0010 0011 1100 1011 1101 1101 1101 1101 1011 1100 1110
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 408 533 913 893 198 798(10) Base 10 integer number converted and written as a signed binary code (in base 2):
-4 408 533 913 893 198 798(10) = 1011 1101 0010 1110 0100 0010 0011 1100 1011 1101 1101 1101 1101 1011 1100 1110
Spaces were used to group digits: for binary, by 4, for decimal, by 3.