To convert integer to binary, start with the integer in question and divide it by 2 keeping notice of the quotient and the remainder. Continue dividing the quotient by 2 until you get a quotient of zero. Then just write out the remainders in the reverse order.
Here is an example of such conversion using the integer 12.
First, let’s divide the number by two specifying quotient and remainder:
-
$12 / 2 = 6$ rest$0$ -
$6 / 2 = 3$ rest$0$ -
$3 / 2 = 1$ rest$1$ -
$1 / 2 = 0$ rest$1$
So we've to write it in the reverse order, 12 in binary is 1100
Example: Calculate 0.625 in binary:
-
$0.625 * 2 = 1.250$ keep$1$ -
$0.250 * 2 = 0.5$ keep$0$ -
$0.5 * 2 = 1$ keep$1$
So, 0.625 in binary is 0.101
Example: Calculate 0.505 in binary:
-
$0.525 * 2 = 1.050$ keep$1$ -
$0.050 * 2 = 0.1$ keep$0$ -
$0.1 * 2 = 0.2$ keep$0$ -
$0.2 * 2 = 0.4$ keep$0$ -
$0.4 * 2 = 0.8$ keep$0$ -
$0.8 * 2 = 1.6$ keep$1$ -
$0.6 * 2 = 1.2$ keep$1$ -
$0.2 * 2 = 1.2$ keep$1$