What are the required steps to convert base 10 integer
number 8 082 737 884 327 668 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;
- 8 082 737 884 327 668 ÷ 2 = 4 041 368 942 163 834 + 0;
- 4 041 368 942 163 834 ÷ 2 = 2 020 684 471 081 917 + 0;
- 2 020 684 471 081 917 ÷ 2 = 1 010 342 235 540 958 + 1;
- 1 010 342 235 540 958 ÷ 2 = 505 171 117 770 479 + 0;
- 505 171 117 770 479 ÷ 2 = 252 585 558 885 239 + 1;
- 252 585 558 885 239 ÷ 2 = 126 292 779 442 619 + 1;
- 126 292 779 442 619 ÷ 2 = 63 146 389 721 309 + 1;
- 63 146 389 721 309 ÷ 2 = 31 573 194 860 654 + 1;
- 31 573 194 860 654 ÷ 2 = 15 786 597 430 327 + 0;
- 15 786 597 430 327 ÷ 2 = 7 893 298 715 163 + 1;
- 7 893 298 715 163 ÷ 2 = 3 946 649 357 581 + 1;
- 3 946 649 357 581 ÷ 2 = 1 973 324 678 790 + 1;
- 1 973 324 678 790 ÷ 2 = 986 662 339 395 + 0;
- 986 662 339 395 ÷ 2 = 493 331 169 697 + 1;
- 493 331 169 697 ÷ 2 = 246 665 584 848 + 1;
- 246 665 584 848 ÷ 2 = 123 332 792 424 + 0;
- 123 332 792 424 ÷ 2 = 61 666 396 212 + 0;
- 61 666 396 212 ÷ 2 = 30 833 198 106 + 0;
- 30 833 198 106 ÷ 2 = 15 416 599 053 + 0;
- 15 416 599 053 ÷ 2 = 7 708 299 526 + 1;
- 7 708 299 526 ÷ 2 = 3 854 149 763 + 0;
- 3 854 149 763 ÷ 2 = 1 927 074 881 + 1;
- 1 927 074 881 ÷ 2 = 963 537 440 + 1;
- 963 537 440 ÷ 2 = 481 768 720 + 0;
- 481 768 720 ÷ 2 = 240 884 360 + 0;
- 240 884 360 ÷ 2 = 120 442 180 + 0;
- 120 442 180 ÷ 2 = 60 221 090 + 0;
- 60 221 090 ÷ 2 = 30 110 545 + 0;
- 30 110 545 ÷ 2 = 15 055 272 + 1;
- 15 055 272 ÷ 2 = 7 527 636 + 0;
- 7 527 636 ÷ 2 = 3 763 818 + 0;
- 3 763 818 ÷ 2 = 1 881 909 + 0;
- 1 881 909 ÷ 2 = 940 954 + 1;
- 940 954 ÷ 2 = 470 477 + 0;
- 470 477 ÷ 2 = 235 238 + 1;
- 235 238 ÷ 2 = 117 619 + 0;
- 117 619 ÷ 2 = 58 809 + 1;
- 58 809 ÷ 2 = 29 404 + 1;
- 29 404 ÷ 2 = 14 702 + 0;
- 14 702 ÷ 2 = 7 351 + 0;
- 7 351 ÷ 2 = 3 675 + 1;
- 3 675 ÷ 2 = 1 837 + 1;
- 1 837 ÷ 2 = 918 + 1;
- 918 ÷ 2 = 459 + 0;
- 459 ÷ 2 = 229 + 1;
- 229 ÷ 2 = 114 + 1;
- 114 ÷ 2 = 57 + 0;
- 57 ÷ 2 = 28 + 1;
- 28 ÷ 2 = 14 + 0;
- 14 ÷ 2 = 7 + 0;
- 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.
8 082 737 884 327 668(10) = 1 1100 1011 0111 0011 0101 0001 0000 0110 1000 0110 1110 1111 0100(2)
3. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 53.
- 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, 53,
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:
8 082 737 884 327 668(10) Base 10 integer number converted and written as a signed binary code (in base 2):
8 082 737 884 327 668(10) = 0000 0000 0001 1100 1011 0111 0011 0101 0001 0000 0110 1000 0110 1110 1111 0100
Spaces were used to group digits: for binary, by 4, for decimal, by 3.