Skip to content
This repository
Newer
Older
100644 109 lines (89 sloc) 5.181 kb
652c8897 » praveenRamalingam
2011-11-22 Added new exercise Understanding moving the decimal
1 <!DOCTYPE html>
c95dba69 » praveenRamalingam
2011-11-29 Removed the use of word-problems.
2 <html data-require="math graphie graphie-helpers-arithmetic">
652c8897 » praveenRamalingam
2011-11-22 Added new exercise Understanding moving the decimal
3 <head>
4e4cb9b1 » beneater
2012-04-10 lint: tabs->spaces and jQuery->$ for exercises
4 <meta charset="UTF-8" />
5 <title>Understanding moving the decimal</title>
6 <script src="../khan-exercise.js"></script>
652c8897 » praveenRamalingam
2011-11-22 Added new exercise Understanding moving the decimal
7 </head>
8 <body>
4e4cb9b1 » beneater
2012-04-10 lint: tabs->spaces and jQuery->$ for exercises
9 <div class="exercise">
10 <div class="vars">
11 <var id="PM">randRangeNonZero( -1, 1 )</var>
12 <var id="OPERATOR">( PM === 1 ? "multiply" : "divide" )</var>
13 <var id="A">randRange( 0, 99999 )</var>
14
15 <div data-ensure="( PM === 1 ? A_DECIMAL > B_DECIMAL : A_DECIMAL < B_DECIMAL )">
16 <var id="A_DECIMAL">randRange( 1, 5 )</var>
17 <var id="B_DECIMAL">randRange( 1, 5 )</var>
18 </div>
19
20 <var id="A_FLOAT">A / pow( 10, A_DECIMAL )</var>
21 <var id="B_FLOAT">A / pow( 10, B_DECIMAL )</var>
22 <var id="POW_DIFF">( PM === 1 ? ( A_DECIMAL - B_DECIMAL ) : ( B_DECIMAL - A_DECIMAL ) )</var>
23 </div>
24
25 <div class="problems">
26 <div>
27 <div class="question">
28 <p><b>How many times do you need to <var>OPERATOR</var> <code><var>A_FLOAT.toFixed( A_DECIMAL )</var></code> by ten to get <code><var>B_FLOAT.toFixed( B_DECIMAL )</var></code>?</b></p>
29 </div>
30
31 <p class="solution" data-forms="integer"><var>POW_DIFF</var></p>
32
33 </div>
34 </div>
35
36 <div class="hints">
37 <div class="graphie">
38 init({
39 range: [ [ -1, 11 ], [ -1, 3 ] ],
064281ea » beneater
2012-09-19 Fix up exercises that are too wide for tutorials
40 scale: [20, 40]
4e4cb9b1 » beneater
2012-04-10 lint: tabs->spaces and jQuery->$ for exercises
41 });
42
43 var digitsA = KhanUtil.digits( A );
44
45 //Pad zeroes if need be for the decimal point
46 while ( digitsA.length &lt; A_DECIMAL + 1) {
47 digitsA.push( 0 );
48 }
49
50 var digitsB = digitsA.slice();
51
52 //For the leading zero 0.# only occurs with division
53 if ( digitsA.length &lt; B_DECIMAL + 1) {
54 digitsA.push( ' ' );
55 digitsB.push( 0 );
56 }
57
58 drawDigits( digitsA.reverse(), 0, 1);
59 drawDigits( digitsB.reverse(), 0, 0);
60
61 for ( var i = 0; i &lt; POW_DIFF; i++) {
62 if ( PM === 1 ) {
63 arc( [ digitsA.length - A_DECIMAL + i, 1.5 ], 0.5, 0, 180, { stroke: "blue" } );
64 label( [ digitsA.length - A_DECIMAL + i, 2 ], i+1, "above" );
65
66 if ( i === POW_DIFF - 1 ) {
67 //hack for the final arrow...is there a better way?
68 line( [ digitsA.length - A_DECIMAL + i + 0.5, 1.5 ], [ digitsA.length - A_DECIMAL + i + 0.5, 1.46 ], { stroke: "blue", arrows: "->" } );
69 }
70 }
71 else {
72 //to draw the final arrow
73 if ( i === POW_DIFF - 1 ) {
74 style({ arrows: "->" });
75 }
76
77 arc( [ digitsA.length - A_DECIMAL - (i + 1), 1.5 ], 0.5, 0, 180, { stroke: "blue" } );
78 label( [ digitsA.length - A_DECIMAL - (i + 1), 2 ], i+1, "above" );
79 }
80 }
81
82 //draw a black ellipse to be used as a decimal point
83 style({ fill: "#000" });
84 ellipse( [ digitsA.length - A_DECIMAL - 0.5, 0.8 ], [ 0.09, 0.06 ] );
85 ellipse( [ digitsB.length - B_DECIMAL - 0.5, -0.2 ], [ 0.09, 0.06 ] );
86
064281ea » beneater
2012-09-19 Fix up exercises that are too wide for tutorials
87 var labelstr = "The decimal point needs to be moved " + POW_DIFF + " time" + ( POW_DIFF !== 1 ? "s." : ".");
88 label ([ digitsA.length + 0.5, 0.5 ], labelstr, "right", false);
4e4cb9b1 » beneater
2012-04-10 lint: tabs->spaces and jQuery->$ for exercises
89 </div>
90
91 <p>Moving the decimal one position to the <var>PM === 1 ? "right" : "left"</var> is the same as <var>PM === 1 ? "multiplying" : "dividing"</var> by ten once.</p>
92
93 <div data-if="PM === 1 && POW_DIFF !== 1">
94 <p data-if="POW_DIFF !== 1">Thus, moving the decimal right <code><var>POW_DIFF</var></code> times is the same as multiplying by ten <code><var>POW_DIFF</var></code> times, or multiplying by <code><var>pow( 10, POW_DIFF )</var></code>:</p>
95 <p><code>{<var>A_FLOAT.toFixed( A_DECIMAL )</var>} * {<var>pow( 10, POW_DIFF )</var>} = {<var>B_FLOAT.toFixed( B_DECIMAL )</var>}</code></p>
96 </div>
97 <div data-if="PM !== 1 && POW_DIFF !== 1">
98 <p data-if="POW_DIFF !== 1">Thus, moving the decimal left <code><var>POW_DIFF</var></code> times is the same as dividing by ten <code><var>POW_DIFF</var></code> times, or dividing by <code><var>pow( 10, POW_DIFF )</var></code>:</p>
99 <p><code>{<var>A_FLOAT.toFixed( A_DECIMAL )</var>} \div {<var>pow( 10, POW_DIFF )</var>} = {<var>B_FLOAT.toFixed( B_DECIMAL )</var>}</code></p>
100 </div>
101
102 <div>
103 <p><b>You need to <var>OPERATOR</var> by ten <code><var>POW_DIFF</var></code> time<span data-if="POW_DIFF !== 1">s</span>.</b></p>
104 </div>
105
106 </div>
107 </div>
652c8897 » praveenRamalingam
2011-11-22 Added new exercise Understanding moving the decimal
108 </body>
bf6a2d84 » beneater
2012-01-07 Make circle round; 10->ten; whitespace
109 </html>
Something went wrong with that request. Please try again.