# Converting between Decimal & Binary.

## Decimal to binary.

This can require many steps. At each step we simply divide the number by 2, until this finally results in a value of 0.
The remainder produced in each step (including any final remainder), give the digits of the binary conversion from l.s.b. to m.s.b.

e.g. converting 287 to binary;

• (l.s.b) 287/2 = 143 remainder 1.
• 143/2 =  71 remainder 1.
• 71/2 =  35 remainder 1.
• 35/2 =  17 remainder 1.
• 17/2 =  8 remainder 1.
• 8/2 =   4 remainder 0.
• 4/2 =   2 remainder 0.
• 2/2 =   1 remainder 0.
• (m.s.b.) 1/2 =   0 remainder 1.

Therefore 287 decimal, = 100011111 binary.

Example converting 65 to binary;

• (l.s.b) 65/2 = 32 remainder 1.
• 32/2 = 16 remainder 0.
• 16/2 =  8 remainder 0.
• 8/2 =  4 remainder 0.
• 4/2 =  2 remainder 0.
• 2/2 =  1 remainder 0.
• (m.s.b.) 1/2 =  0 remainder 1.

Therefore 65 decimal = 1000001 binary.

## Binary to decimal.

To convert a binary number to decimal, then for each bit in the number that is 1, we simply add the digit weightings together.

e.g. 1100 1011. Therefore 1100 1011 binary, = 203 decimal.