This write up is straight from the top of my head to this page, okay? After the procedure is an example showing how it works. I hope people like it.
Procedure to Convert a Decimal Number to Binary
Assumptions: Range is 8 bits = decimal numbers from 0-255. The binary digits (bits) are 128, 64, 32, 16, 8, 4, 2, and 1.
a. For every bit (binary digit) that is larger than your original decimal number, write a zero ("0").
b. Write a one ("1") for the first bit that matches or is smaller than your original decimal number.
c. Subtract that "bit" from your decimal number to get a remainder.
d. If the remainder is zero (0) then you are done. Write a zero ("0") for all the smaller bits and stop.
e. Otherwise, take the remainder and keep going with the same process. For every binary digit that is larger than the remainder, write a "0".
f. Write a one ("1") for the first bit that matches or is smaller than your remainder.
g. Subtract that "bit" from your remainder to get a new remainder.
h. If the new remainder is zero (0) then you are done. Write a zero for all the remaining smaller bits.
i. Repeat steps "e" through "h" for each new remainder that is not zero.
Example - If your number is "22":
a. Write a zero ("0") for the bits 128, 64, and 32 because those bits are larger than 22.
b. Write a one ("1") for bit 16 because 16 is the first bit that is matches or is smaller than 22.
c. Subtract 22 - 16 = 6. Your new remainder is 6.
d. The remainder is 6, not zero. Keep going.
e[1]. Write a zero ("0") for bit 8, because 8 is larger than your current remainder 6.
f[1]. Write a one ("1") for bit 4, because 4 is the first bit that is matching or smaller than your current remainder 6.
g[1]. Subtract 6 - 4 = 2. Your new remainder is 2.
h[1]. The new remainder is 2, not zero.
i. Go back to step e (step "e(2)", below) with your new remainder, 2.
e[2]. There are no bits left that are larger than your new remainder, 2.
f[2]. Write a one ("1") for bit 2, because bit 2 matches your current remainder 2.
g[2]. Subtract 2 - 2 = 0. Your new remainder is 0.
h[2]. The new remainder is zero after subtracting the two bit, so you are done. Write a zero ("0") for the 1 bit and you have your answer.
Answer: 22 = 00010110 (128=0, 64=0, 32=0, 16=1, 8=0, 4=1, 2=1, 1=0)