What are the required steps to convert base 10 integer
number -5 243 678 498 844 836 030 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:
|-5 243 678 498 844 836 030| = 5 243 678 498 844 836 030
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;
- 5 243 678 498 844 836 030 ÷ 2 = 2 621 839 249 422 418 015 + 0;
- 2 621 839 249 422 418 015 ÷ 2 = 1 310 919 624 711 209 007 + 1;
- 1 310 919 624 711 209 007 ÷ 2 = 655 459 812 355 604 503 + 1;
- 655 459 812 355 604 503 ÷ 2 = 327 729 906 177 802 251 + 1;
- 327 729 906 177 802 251 ÷ 2 = 163 864 953 088 901 125 + 1;
- 163 864 953 088 901 125 ÷ 2 = 81 932 476 544 450 562 + 1;
- 81 932 476 544 450 562 ÷ 2 = 40 966 238 272 225 281 + 0;
- 40 966 238 272 225 281 ÷ 2 = 20 483 119 136 112 640 + 1;
- 20 483 119 136 112 640 ÷ 2 = 10 241 559 568 056 320 + 0;
- 10 241 559 568 056 320 ÷ 2 = 5 120 779 784 028 160 + 0;
- 5 120 779 784 028 160 ÷ 2 = 2 560 389 892 014 080 + 0;
- 2 560 389 892 014 080 ÷ 2 = 1 280 194 946 007 040 + 0;
- 1 280 194 946 007 040 ÷ 2 = 640 097 473 003 520 + 0;
- 640 097 473 003 520 ÷ 2 = 320 048 736 501 760 + 0;
- 320 048 736 501 760 ÷ 2 = 160 024 368 250 880 + 0;
- 160 024 368 250 880 ÷ 2 = 80 012 184 125 440 + 0;
- 80 012 184 125 440 ÷ 2 = 40 006 092 062 720 + 0;
- 40 006 092 062 720 ÷ 2 = 20 003 046 031 360 + 0;
- 20 003 046 031 360 ÷ 2 = 10 001 523 015 680 + 0;
- 10 001 523 015 680 ÷ 2 = 5 000 761 507 840 + 0;
- 5 000 761 507 840 ÷ 2 = 2 500 380 753 920 + 0;
- 2 500 380 753 920 ÷ 2 = 1 250 190 376 960 + 0;
- 1 250 190 376 960 ÷ 2 = 625 095 188 480 + 0;
- 625 095 188 480 ÷ 2 = 312 547 594 240 + 0;
- 312 547 594 240 ÷ 2 = 156 273 797 120 + 0;
- 156 273 797 120 ÷ 2 = 78 136 898 560 + 0;
- 78 136 898 560 ÷ 2 = 39 068 449 280 + 0;
- 39 068 449 280 ÷ 2 = 19 534 224 640 + 0;
- 19 534 224 640 ÷ 2 = 9 767 112 320 + 0;
- 9 767 112 320 ÷ 2 = 4 883 556 160 + 0;
- 4 883 556 160 ÷ 2 = 2 441 778 080 + 0;
- 2 441 778 080 ÷ 2 = 1 220 889 040 + 0;
- 1 220 889 040 ÷ 2 = 610 444 520 + 0;
- 610 444 520 ÷ 2 = 305 222 260 + 0;
- 305 222 260 ÷ 2 = 152 611 130 + 0;
- 152 611 130 ÷ 2 = 76 305 565 + 0;
- 76 305 565 ÷ 2 = 38 152 782 + 1;
- 38 152 782 ÷ 2 = 19 076 391 + 0;
- 19 076 391 ÷ 2 = 9 538 195 + 1;
- 9 538 195 ÷ 2 = 4 769 097 + 1;
- 4 769 097 ÷ 2 = 2 384 548 + 1;
- 2 384 548 ÷ 2 = 1 192 274 + 0;
- 1 192 274 ÷ 2 = 596 137 + 0;
- 596 137 ÷ 2 = 298 068 + 1;
- 298 068 ÷ 2 = 149 034 + 0;
- 149 034 ÷ 2 = 74 517 + 0;
- 74 517 ÷ 2 = 37 258 + 1;
- 37 258 ÷ 2 = 18 629 + 0;
- 18 629 ÷ 2 = 9 314 + 1;
- 9 314 ÷ 2 = 4 657 + 0;
- 4 657 ÷ 2 = 2 328 + 1;
- 2 328 ÷ 2 = 1 164 + 0;
- 1 164 ÷ 2 = 582 + 0;
- 582 ÷ 2 = 291 + 0;
- 291 ÷ 2 = 145 + 1;
- 145 ÷ 2 = 72 + 1;
- 72 ÷ 2 = 36 + 0;
- 36 ÷ 2 = 18 + 0;
- 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.
5 243 678 498 844 836 030(10) = 100 1000 1100 0101 0100 1001 1101 0000 0000 0000 0000 0000 0000 0000 1011 1110(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:
5 243 678 498 844 836 030(10) = 0100 1000 1100 0101 0100 1001 1101 0000 0000 0000 0000 0000 0000 0000 1011 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...
-5 243 678 498 844 836 030(10) Base 10 integer number converted and written as a signed binary code (in base 2):
-5 243 678 498 844 836 030(10) = 1100 1000 1100 0101 0100 1001 1101 0000 0000 0000 0000 0000 0000 0000 1011 1110
Spaces were used to group digits: for binary, by 4, for decimal, by 3.