What are the required steps to convert base 10 integer
number 10 110 001 100 154 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;
- 10 110 001 100 154 ÷ 2 = 5 055 000 550 077 + 0;
- 5 055 000 550 077 ÷ 2 = 2 527 500 275 038 + 1;
- 2 527 500 275 038 ÷ 2 = 1 263 750 137 519 + 0;
- 1 263 750 137 519 ÷ 2 = 631 875 068 759 + 1;
- 631 875 068 759 ÷ 2 = 315 937 534 379 + 1;
- 315 937 534 379 ÷ 2 = 157 968 767 189 + 1;
- 157 968 767 189 ÷ 2 = 78 984 383 594 + 1;
- 78 984 383 594 ÷ 2 = 39 492 191 797 + 0;
- 39 492 191 797 ÷ 2 = 19 746 095 898 + 1;
- 19 746 095 898 ÷ 2 = 9 873 047 949 + 0;
- 9 873 047 949 ÷ 2 = 4 936 523 974 + 1;
- 4 936 523 974 ÷ 2 = 2 468 261 987 + 0;
- 2 468 261 987 ÷ 2 = 1 234 130 993 + 1;
- 1 234 130 993 ÷ 2 = 617 065 496 + 1;
- 617 065 496 ÷ 2 = 308 532 748 + 0;
- 308 532 748 ÷ 2 = 154 266 374 + 0;
- 154 266 374 ÷ 2 = 77 133 187 + 0;
- 77 133 187 ÷ 2 = 38 566 593 + 1;
- 38 566 593 ÷ 2 = 19 283 296 + 1;
- 19 283 296 ÷ 2 = 9 641 648 + 0;
- 9 641 648 ÷ 2 = 4 820 824 + 0;
- 4 820 824 ÷ 2 = 2 410 412 + 0;
- 2 410 412 ÷ 2 = 1 205 206 + 0;
- 1 205 206 ÷ 2 = 602 603 + 0;
- 602 603 ÷ 2 = 301 301 + 1;
- 301 301 ÷ 2 = 150 650 + 1;
- 150 650 ÷ 2 = 75 325 + 0;
- 75 325 ÷ 2 = 37 662 + 1;
- 37 662 ÷ 2 = 18 831 + 0;
- 18 831 ÷ 2 = 9 415 + 1;
- 9 415 ÷ 2 = 4 707 + 1;
- 4 707 ÷ 2 = 2 353 + 1;
- 2 353 ÷ 2 = 1 176 + 1;
- 1 176 ÷ 2 = 588 + 0;
- 588 ÷ 2 = 294 + 0;
- 294 ÷ 2 = 147 + 0;
- 147 ÷ 2 = 73 + 1;
- 73 ÷ 2 = 36 + 1;
- 36 ÷ 2 = 18 + 0;
- 18 ÷ 2 = 9 + 0;
- 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.
10 110 001 100 154(10) = 1001 0011 0001 1110 1011 0000 0110 0011 0101 0111 1010(2)
3. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 44.
- 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, 44,
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:
10 110 001 100 154(10) Base 10 integer number converted and written as a signed binary code (in base 2):
10 110 001 100 154(10) = 0000 0000 0000 0000 0000 1001 0011 0001 1110 1011 0000 0110 0011 0101 0111 1010
Spaces were used to group digits: for binary, by 4, for decimal, by 3.