What are the required steps to convert base 10 integer
number 34 246 565 387 542 654 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. 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;
- 34 246 565 387 542 654 ÷ 2 = 17 123 282 693 771 327 + 0;
- 17 123 282 693 771 327 ÷ 2 = 8 561 641 346 885 663 + 1;
- 8 561 641 346 885 663 ÷ 2 = 4 280 820 673 442 831 + 1;
- 4 280 820 673 442 831 ÷ 2 = 2 140 410 336 721 415 + 1;
- 2 140 410 336 721 415 ÷ 2 = 1 070 205 168 360 707 + 1;
- 1 070 205 168 360 707 ÷ 2 = 535 102 584 180 353 + 1;
- 535 102 584 180 353 ÷ 2 = 267 551 292 090 176 + 1;
- 267 551 292 090 176 ÷ 2 = 133 775 646 045 088 + 0;
- 133 775 646 045 088 ÷ 2 = 66 887 823 022 544 + 0;
- 66 887 823 022 544 ÷ 2 = 33 443 911 511 272 + 0;
- 33 443 911 511 272 ÷ 2 = 16 721 955 755 636 + 0;
- 16 721 955 755 636 ÷ 2 = 8 360 977 877 818 + 0;
- 8 360 977 877 818 ÷ 2 = 4 180 488 938 909 + 0;
- 4 180 488 938 909 ÷ 2 = 2 090 244 469 454 + 1;
- 2 090 244 469 454 ÷ 2 = 1 045 122 234 727 + 0;
- 1 045 122 234 727 ÷ 2 = 522 561 117 363 + 1;
- 522 561 117 363 ÷ 2 = 261 280 558 681 + 1;
- 261 280 558 681 ÷ 2 = 130 640 279 340 + 1;
- 130 640 279 340 ÷ 2 = 65 320 139 670 + 0;
- 65 320 139 670 ÷ 2 = 32 660 069 835 + 0;
- 32 660 069 835 ÷ 2 = 16 330 034 917 + 1;
- 16 330 034 917 ÷ 2 = 8 165 017 458 + 1;
- 8 165 017 458 ÷ 2 = 4 082 508 729 + 0;
- 4 082 508 729 ÷ 2 = 2 041 254 364 + 1;
- 2 041 254 364 ÷ 2 = 1 020 627 182 + 0;
- 1 020 627 182 ÷ 2 = 510 313 591 + 0;
- 510 313 591 ÷ 2 = 255 156 795 + 1;
- 255 156 795 ÷ 2 = 127 578 397 + 1;
- 127 578 397 ÷ 2 = 63 789 198 + 1;
- 63 789 198 ÷ 2 = 31 894 599 + 0;
- 31 894 599 ÷ 2 = 15 947 299 + 1;
- 15 947 299 ÷ 2 = 7 973 649 + 1;
- 7 973 649 ÷ 2 = 3 986 824 + 1;
- 3 986 824 ÷ 2 = 1 993 412 + 0;
- 1 993 412 ÷ 2 = 996 706 + 0;
- 996 706 ÷ 2 = 498 353 + 0;
- 498 353 ÷ 2 = 249 176 + 1;
- 249 176 ÷ 2 = 124 588 + 0;
- 124 588 ÷ 2 = 62 294 + 0;
- 62 294 ÷ 2 = 31 147 + 0;
- 31 147 ÷ 2 = 15 573 + 1;
- 15 573 ÷ 2 = 7 786 + 1;
- 7 786 ÷ 2 = 3 893 + 0;
- 3 893 ÷ 2 = 1 946 + 1;
- 1 946 ÷ 2 = 973 + 0;
- 973 ÷ 2 = 486 + 1;
- 486 ÷ 2 = 243 + 0;
- 243 ÷ 2 = 121 + 1;
- 121 ÷ 2 = 60 + 1;
- 60 ÷ 2 = 30 + 0;
- 30 ÷ 2 = 15 + 0;
- 15 ÷ 2 = 7 + 1;
- 7 ÷ 2 = 3 + 1;
- 3 ÷ 2 = 1 + 1;
- 1 ÷ 2 = 0 + 1;
2. Construct the base 2 representation of the positive number:
Take all the remainders starting from the bottom of the list constructed above.
34 246 565 387 542 654(10) = 111 1001 1010 1011 0001 0001 1101 1100 1011 0011 1010 0000 0111 1110(2)
3. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 55.
- 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, 55,
3) so that the first bit (leftmost) could be zero
(we deal with a positive number at this moment)
=== is: 64.
4. 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:
34 246 565 387 542 654(10) Base 10 integer number converted and written as a signed binary code (in base 2):
34 246 565 387 542 654(10) = 0000 0000 0111 1001 1010 1011 0001 0001 1101 1100 1011 0011 1010 0000 0111 1110
Spaces were used to group digits: for binary, by 4, for decimal, by 3.