1. Divide the number repeatedly by 2:
Keep track of each remainder.
We stop when we get a quotient that is equal to zero.
- division = quotient + remainder;
- 16 338 509 ÷ 2 = 8 169 254 + 1;
- 8 169 254 ÷ 2 = 4 084 627 + 0;
- 4 084 627 ÷ 2 = 2 042 313 + 1;
- 2 042 313 ÷ 2 = 1 021 156 + 1;
- 1 021 156 ÷ 2 = 510 578 + 0;
- 510 578 ÷ 2 = 255 289 + 0;
- 255 289 ÷ 2 = 127 644 + 1;
- 127 644 ÷ 2 = 63 822 + 0;
- 63 822 ÷ 2 = 31 911 + 0;
- 31 911 ÷ 2 = 15 955 + 1;
- 15 955 ÷ 2 = 7 977 + 1;
- 7 977 ÷ 2 = 3 988 + 1;
- 3 988 ÷ 2 = 1 994 + 0;
- 1 994 ÷ 2 = 997 + 0;
- 997 ÷ 2 = 498 + 1;
- 498 ÷ 2 = 249 + 0;
- 249 ÷ 2 = 124 + 1;
- 124 ÷ 2 = 62 + 0;
- 62 ÷ 2 = 31 + 0;
- 31 ÷ 2 = 15 + 1;
- 15 ÷ 2 = 7 + 1;
- 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.
16 338 509(10) = 1111 1001 0100 1110 0100 1101(2)
3. Determine the signed binary number bit length:
The base 2 number's actual length, in bits: 24.
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, 24,
3) so that the first bit (leftmost) could be zero
(we deal with a positive number at this moment)
=== is: 32.
4. Get the positive binary computer representation on 32 bits (4 Bytes):
If needed, add extra 0s in front (to the left) of the base 2 number, up to the required length, 32:
Number 16 338 509(10), a signed integer number (with sign),
converted from decimal system (from base 10)
and written as a signed binary (in base 2):
16 338 509(10) = 0000 0000 1111 1001 0100 1110 0100 1101
Spaces were used to group digits: for binary, by 4, for decimal, by 3.