What are the required steps to convert base 10 integer
number 189 999 999 453 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;
- 189 999 999 453 ÷ 2 = 94 999 999 726 + 1;
- 94 999 999 726 ÷ 2 = 47 499 999 863 + 0;
- 47 499 999 863 ÷ 2 = 23 749 999 931 + 1;
- 23 749 999 931 ÷ 2 = 11 874 999 965 + 1;
- 11 874 999 965 ÷ 2 = 5 937 499 982 + 1;
- 5 937 499 982 ÷ 2 = 2 968 749 991 + 0;
- 2 968 749 991 ÷ 2 = 1 484 374 995 + 1;
- 1 484 374 995 ÷ 2 = 742 187 497 + 1;
- 742 187 497 ÷ 2 = 371 093 748 + 1;
- 371 093 748 ÷ 2 = 185 546 874 + 0;
- 185 546 874 ÷ 2 = 92 773 437 + 0;
- 92 773 437 ÷ 2 = 46 386 718 + 1;
- 46 386 718 ÷ 2 = 23 193 359 + 0;
- 23 193 359 ÷ 2 = 11 596 679 + 1;
- 11 596 679 ÷ 2 = 5 798 339 + 1;
- 5 798 339 ÷ 2 = 2 899 169 + 1;
- 2 899 169 ÷ 2 = 1 449 584 + 1;
- 1 449 584 ÷ 2 = 724 792 + 0;
- 724 792 ÷ 2 = 362 396 + 0;
- 362 396 ÷ 2 = 181 198 + 0;
- 181 198 ÷ 2 = 90 599 + 0;
- 90 599 ÷ 2 = 45 299 + 1;
- 45 299 ÷ 2 = 22 649 + 1;
- 22 649 ÷ 2 = 11 324 + 1;
- 11 324 ÷ 2 = 5 662 + 0;
- 5 662 ÷ 2 = 2 831 + 0;
- 2 831 ÷ 2 = 1 415 + 1;
- 1 415 ÷ 2 = 707 + 1;
- 707 ÷ 2 = 353 + 1;
- 353 ÷ 2 = 176 + 1;
- 176 ÷ 2 = 88 + 0;
- 88 ÷ 2 = 44 + 0;
- 44 ÷ 2 = 22 + 0;
- 22 ÷ 2 = 11 + 0;
- 11 ÷ 2 = 5 + 1;
- 5 ÷ 2 = 2 + 1;
- 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.
189 999 999 453(10) = 10 1100 0011 1100 1110 0001 1110 1001 1101 1101(2)
3. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 38.
- 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, 38,
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:
189 999 999 453(10) Base 10 integer number converted and written as a signed binary code (in base 2):
189 999 999 453(10) = 0000 0000 0000 0000 0000 0000 0010 1100 0011 1100 1110 0001 1110 1001 1101 1101
Spaces were used to group digits: for binary, by 4, for decimal, by 3.