go to previous page   go to home page   go to next page

Answer:

20 == 16 + 4

16 is 10000, 4 is 00100, so 20 must be 10100.


Repeated Subtraction Method

The above ideas lead to the repeated subtraction method of converting a reprsentation of a positive integer from decimal to binary.

Algorithm: Convert a positive integer
from base 10 to Binary Representation
number = positive integer;

while (number > 0 )
{
  determine the largest  2B that is less than or equal to number;    
  put a 1 in the B's place of the binary ;
  number = number - 2B ;
}

Put 0s in the binary for the powers of 2 not used;

You are (of course) eager to practice this method. Let us convert 23 to binary.


QUESTION 16:

What is the greatest power of two less than 23?


go to previous page   go to home page   go to next page