What are the required steps to convert base 10 integer
number 694 206 942 069 403 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;
- 694 206 942 069 403 ÷ 2 = 347 103 471 034 701 + 1;
- 347 103 471 034 701 ÷ 2 = 173 551 735 517 350 + 1;
- 173 551 735 517 350 ÷ 2 = 86 775 867 758 675 + 0;
- 86 775 867 758 675 ÷ 2 = 43 387 933 879 337 + 1;
- 43 387 933 879 337 ÷ 2 = 21 693 966 939 668 + 1;
- 21 693 966 939 668 ÷ 2 = 10 846 983 469 834 + 0;
- 10 846 983 469 834 ÷ 2 = 5 423 491 734 917 + 0;
- 5 423 491 734 917 ÷ 2 = 2 711 745 867 458 + 1;
- 2 711 745 867 458 ÷ 2 = 1 355 872 933 729 + 0;
- 1 355 872 933 729 ÷ 2 = 677 936 466 864 + 1;
- 677 936 466 864 ÷ 2 = 338 968 233 432 + 0;
- 338 968 233 432 ÷ 2 = 169 484 116 716 + 0;
- 169 484 116 716 ÷ 2 = 84 742 058 358 + 0;
- 84 742 058 358 ÷ 2 = 42 371 029 179 + 0;
- 42 371 029 179 ÷ 2 = 21 185 514 589 + 1;
- 21 185 514 589 ÷ 2 = 10 592 757 294 + 1;
- 10 592 757 294 ÷ 2 = 5 296 378 647 + 0;
- 5 296 378 647 ÷ 2 = 2 648 189 323 + 1;
- 2 648 189 323 ÷ 2 = 1 324 094 661 + 1;
- 1 324 094 661 ÷ 2 = 662 047 330 + 1;
- 662 047 330 ÷ 2 = 331 023 665 + 0;
- 331 023 665 ÷ 2 = 165 511 832 + 1;
- 165 511 832 ÷ 2 = 82 755 916 + 0;
- 82 755 916 ÷ 2 = 41 377 958 + 0;
- 41 377 958 ÷ 2 = 20 688 979 + 0;
- 20 688 979 ÷ 2 = 10 344 489 + 1;
- 10 344 489 ÷ 2 = 5 172 244 + 1;
- 5 172 244 ÷ 2 = 2 586 122 + 0;
- 2 586 122 ÷ 2 = 1 293 061 + 0;
- 1 293 061 ÷ 2 = 646 530 + 1;
- 646 530 ÷ 2 = 323 265 + 0;
- 323 265 ÷ 2 = 161 632 + 1;
- 161 632 ÷ 2 = 80 816 + 0;
- 80 816 ÷ 2 = 40 408 + 0;
- 40 408 ÷ 2 = 20 204 + 0;
- 20 204 ÷ 2 = 10 102 + 0;
- 10 102 ÷ 2 = 5 051 + 0;
- 5 051 ÷ 2 = 2 525 + 1;
- 2 525 ÷ 2 = 1 262 + 1;
- 1 262 ÷ 2 = 631 + 0;
- 631 ÷ 2 = 315 + 1;
- 315 ÷ 2 = 157 + 1;
- 157 ÷ 2 = 78 + 1;
- 78 ÷ 2 = 39 + 0;
- 39 ÷ 2 = 19 + 1;
- 19 ÷ 2 = 9 + 1;
- 9 ÷ 2 = 4 + 1;
- 4 ÷ 2 = 2 + 0;
- 2 ÷ 2 = 1 + 0;
- 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.
694 206 942 069 403(10) = 10 0111 0111 0110 0000 1010 0110 0010 1110 1100 0010 1001 1011(2)
3. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 50.
- 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, 50,
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:
694 206 942 069 403(10) Base 10 integer number converted and written as a signed binary code (in base 2):
694 206 942 069 403(10) = 0000 0000 0000 0010 0111 0111 0110 0000 1010 0110 0010 1110 1100 0010 1001 1011
Spaces were used to group digits: for binary, by 4, for decimal, by 3.