# Khan/khan-exercises

Also factor out subtracting_decimals

1 parent 95d6db6 commit ad6f4a7f81254ea5dbfc28d643e7d9343770d8c7 spicyj committed Nov 18, 2011
Showing with 67 additions and 63 deletions.
1. +13 −30 exercises/subtracting_decimals.html
2. +54 −33 utils/graphie-helpers-arithmetic.js
 @@ -7,48 +7,31 @@
-
+
randRange( 101, 999 ) randRange( 101, 999 ) + randRange( 1, 3 ) randRange( 1, 3 ) - A * ( B_DECIMAL > A_DECIMAL ? pow( 10, B_DECIMAL - A_DECIMAL ) : 1) - B * ( A_DECIMAL > B_DECIMAL ? pow( 10, A_DECIMAL - B_DECIMAL ) : 1) - - (function() { - var result = digits( NEW_A ); - for ( var i = 0; i < ( A_DECIMAL - B_DECIMAL ) || result.length < A_DECIMAL + 1; i++ ) { - result.push( 0 ); - } - return result; - })() - - (function() { - var result = digits( NEW_B ); - for ( var i = 0; i < ( B_DECIMAL - A_DECIMAL ) || result.length < B_DECIMAL + 1; i++ ) { - result.push( 0 ); - } - return result; - })() + + A / pow( 10, A_DECIMAL ) + B / pow( 10, B_DECIMAL )
-

\Huge{roundTo( A_DECIMAL, A * pow( 10, -A_DECIMAL ) ).toFixed( A_DECIMAL ) - roundTo( B_DECIMAL, B * pow( 10, -B_DECIMAL ) ).toFixed( B_DECIMAL ) = {?}}

-
A * pow( 10, -A_DECIMAL ) - B * pow( 10, - B_DECIMAL )
-
- graph.subtractor = new Subtractor( NEW_A, NEW_B, A_DIGITS, B_DIGITS ); - DUMMY = Array( graph.subtractor.getNumHints() ); -
+

\Huge{A_FLOAT.toFixed( A_DECIMAL ) - B_FLOAT.toFixed( B_DECIMAL ) = {?}}

+
A_FLOAT - B_FLOAT
-
- graph.subtractor.show(); - graph.subtractor.showDecimals( A_DECIMAL, B_DECIMAL ); +