What are the required steps to convert base 10 integer
number 558 350 217 820 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;
- 558 350 217 820 ÷ 2 = 279 175 108 910 + 0;
- 279 175 108 910 ÷ 2 = 139 587 554 455 + 0;
- 139 587 554 455 ÷ 2 = 69 793 777 227 + 1;
- 69 793 777 227 ÷ 2 = 34 896 888 613 + 1;
- 34 896 888 613 ÷ 2 = 17 448 444 306 + 1;
- 17 448 444 306 ÷ 2 = 8 724 222 153 + 0;
- 8 724 222 153 ÷ 2 = 4 362 111 076 + 1;
- 4 362 111 076 ÷ 2 = 2 181 055 538 + 0;
- 2 181 055 538 ÷ 2 = 1 090 527 769 + 0;
- 1 090 527 769 ÷ 2 = 545 263 884 + 1;
- 545 263 884 ÷ 2 = 272 631 942 + 0;
- 272 631 942 ÷ 2 = 136 315 971 + 0;
- 136 315 971 ÷ 2 = 68 157 985 + 1;
- 68 157 985 ÷ 2 = 34 078 992 + 1;
- 34 078 992 ÷ 2 = 17 039 496 + 0;
- 17 039 496 ÷ 2 = 8 519 748 + 0;
- 8 519 748 ÷ 2 = 4 259 874 + 0;
- 4 259 874 ÷ 2 = 2 129 937 + 0;
- 2 129 937 ÷ 2 = 1 064 968 + 1;
- 1 064 968 ÷ 2 = 532 484 + 0;
- 532 484 ÷ 2 = 266 242 + 0;
- 266 242 ÷ 2 = 133 121 + 0;
- 133 121 ÷ 2 = 66 560 + 1;
- 66 560 ÷ 2 = 33 280 + 0;
- 33 280 ÷ 2 = 16 640 + 0;
- 16 640 ÷ 2 = 8 320 + 0;
- 8 320 ÷ 2 = 4 160 + 0;
- 4 160 ÷ 2 = 2 080 + 0;
- 2 080 ÷ 2 = 1 040 + 0;
- 1 040 ÷ 2 = 520 + 0;
- 520 ÷ 2 = 260 + 0;
- 260 ÷ 2 = 130 + 0;
- 130 ÷ 2 = 65 + 0;
- 65 ÷ 2 = 32 + 1;
- 32 ÷ 2 = 16 + 0;
- 16 ÷ 2 = 8 + 0;
- 8 ÷ 2 = 4 + 0;
- 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.
558 350 217 820(10) = 1000 0010 0000 0000 0100 0100 0011 0010 0101 1100(2)
3. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 40.
- 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, 40,
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:
558 350 217 820(10) Base 10 integer number converted and written as a signed binary code (in base 2):
558 350 217 820(10) = 0000 0000 0000 0000 0000 0000 1000 0010 0000 0000 0100 0100 0011 0010 0101 1100
Spaces were used to group digits: for binary, by 4, for decimal, by 3.