What are the required steps to convert base 10 integer
number 233 116 198 035 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;
- 233 116 198 035 ÷ 2 = 116 558 099 017 + 1;
- 116 558 099 017 ÷ 2 = 58 279 049 508 + 1;
- 58 279 049 508 ÷ 2 = 29 139 524 754 + 0;
- 29 139 524 754 ÷ 2 = 14 569 762 377 + 0;
- 14 569 762 377 ÷ 2 = 7 284 881 188 + 1;
- 7 284 881 188 ÷ 2 = 3 642 440 594 + 0;
- 3 642 440 594 ÷ 2 = 1 821 220 297 + 0;
- 1 821 220 297 ÷ 2 = 910 610 148 + 1;
- 910 610 148 ÷ 2 = 455 305 074 + 0;
- 455 305 074 ÷ 2 = 227 652 537 + 0;
- 227 652 537 ÷ 2 = 113 826 268 + 1;
- 113 826 268 ÷ 2 = 56 913 134 + 0;
- 56 913 134 ÷ 2 = 28 456 567 + 0;
- 28 456 567 ÷ 2 = 14 228 283 + 1;
- 14 228 283 ÷ 2 = 7 114 141 + 1;
- 7 114 141 ÷ 2 = 3 557 070 + 1;
- 3 557 070 ÷ 2 = 1 778 535 + 0;
- 1 778 535 ÷ 2 = 889 267 + 1;
- 889 267 ÷ 2 = 444 633 + 1;
- 444 633 ÷ 2 = 222 316 + 1;
- 222 316 ÷ 2 = 111 158 + 0;
- 111 158 ÷ 2 = 55 579 + 0;
- 55 579 ÷ 2 = 27 789 + 1;
- 27 789 ÷ 2 = 13 894 + 1;
- 13 894 ÷ 2 = 6 947 + 0;
- 6 947 ÷ 2 = 3 473 + 1;
- 3 473 ÷ 2 = 1 736 + 1;
- 1 736 ÷ 2 = 868 + 0;
- 868 ÷ 2 = 434 + 0;
- 434 ÷ 2 = 217 + 0;
- 217 ÷ 2 = 108 + 1;
- 108 ÷ 2 = 54 + 0;
- 54 ÷ 2 = 27 + 0;
- 27 ÷ 2 = 13 + 1;
- 13 ÷ 2 = 6 + 1;
- 6 ÷ 2 = 3 + 0;
- 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.
233 116 198 035(10) = 11 0110 0100 0110 1100 1110 1110 0100 1001 0011(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:
233 116 198 035(10) Base 10 integer number converted and written as a signed binary code (in base 2):
233 116 198 035(10) = 0000 0000 0000 0000 0000 0000 0011 0110 0100 0110 1100 1110 1110 0100 1001 0011
Spaces were used to group digits: for binary, by 4, for decimal, by 3.