# Khan/khan-exercises

Fetching contributors…
Cannot retrieve contributors at this time
100 lines (90 sloc) 4.95 KB
 Converting fractions to decimals
randFromArray([4, 5, 8, 10, 20, 25, 50]) * (rand(5) < 2 ? -1 : 1) randRange(1, 99) * (rand(5) < 2 ? -1 : 1) roundTo(4, NUMERATOR / DENOMINATOR)

Express the fraction as a decimal.

\dfrac{NUMERATOR}{DENOMINATOR}

DECIMAL

\dfrac{NUMERATOR}{DENOMINATOR} represents NUMERATOR \div DENOMINATOR .

A negative number divided by a negative number equals a positive number, so NUMERATOR \div DENOMINATOR = -NUMERATOR \div -DENOMINATOR

\begin{eqnarray} NUMERATOR \div DENOMINATOR &=& (-1 \times -NUMERATOR) \div DENOMINATOR \\ &=& -1 \times (-NUMERATOR \div DENOMINATOR) \end{eqnarray}

\begin{eqnarray} NUMERATOR \div DENOMINATOR &=& NUMERATOR \div (-1 \times -DENOMINATOR) \\ &=& -1 \times (NUMERATOR \div -DENOMINATOR) \end{eqnarray}

graph.divider = new Divider(abs(DENOMINATOR), abs(NUMERATOR), 0, 0, true); graph.divider.show();
graph.divider.showHint();

\begin{eqnarray} \dfrac{NUMERATOR}{DENOMINATOR} &=& -1 \times (abs(NUMERATOR) \div abs(DENOMINATOR)) \\ &=& -1 \times -DECIMAL \\ &=& DECIMAL \end{eqnarray}

\dfrac{NUMERATOR}{DENOMINATOR} = DECIMAL

randFromArray([3, 6, 9, 30]) randRange(1, 98) roundTo(4, NUMERATOR / DENOMINATOR)

Express the fraction as a decimal.

Round to 4 decimal places if necessary.

\dfrac{NUMERATOR}{DENOMINATOR}

DECIMAL

\dfrac{NUMERATOR}{DENOMINATOR} represents NUMERATOR \div DENOMINATOR .

graph.divider = new Divider(abs(DENOMINATOR), abs(NUMERATOR), 0, 0, true); graph.divider.show();
graph.divider.showHint();

Notice how the decimal is repeating and will continue to repeat as we bring down more zeros.

So the answer is DECIMAL to 4 decimal places.