Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 110 lines (89 sloc) 4.198 kb
652c889 @praveenRamalingam Added new exercise Understanding moving the decimal
praveenRamalingam authored
1 <!DOCTYPE html>
c95dba6 @praveenRamalingam Removed the use of word-problems.
praveenRamalingam authored
2 <html data-require="math graphie graphie-helpers-arithmetic">
652c889 @praveenRamalingam Added new exercise Understanding moving the decimal
praveenRamalingam authored
3 <head>
4 <meta charset="UTF-8" />
5 <title>Understanding moving the decimal</title>
6 <script src="../khan-exercise.js"></script>
7 </head>
8 <body>
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>
bf6a2d8 @beneater Make circle round; 10->ten; whitespace
beneater authored
14
652c889 @praveenRamalingam Added new exercise Understanding moving the decimal
praveenRamalingam authored
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>
bf6a2d8 @beneater Make circle round; 10->ten; whitespace
beneater authored
19
652c889 @praveenRamalingam Added new exercise Understanding moving the decimal
praveenRamalingam authored
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>
bf6a2d8 @beneater Make circle round; 10->ten; whitespace
beneater authored
24
652c889 @praveenRamalingam Added new exercise Understanding moving the decimal
praveenRamalingam authored
25 <div class="problems">
26 <div>
27 <div class="question">
bf6a2d8 @beneater Make circle round; 10->ten; whitespace
beneater authored
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>
652c889 @praveenRamalingam Added new exercise Understanding moving the decimal
praveenRamalingam authored
29 </div>
bf6a2d8 @beneater Make circle round; 10->ten; whitespace
beneater authored
30
652c889 @praveenRamalingam Added new exercise Understanding moving the decimal
praveenRamalingam authored
31 <p class="solution" data-forms="integer"><var>POW_DIFF</var></p>
bf6a2d8 @beneater Make circle round; 10->ten; whitespace
beneater authored
32
652c889 @praveenRamalingam Added new exercise Understanding moving the decimal
praveenRamalingam authored
33 </div>
34 </div>
bf6a2d8 @beneater Make circle round; 10->ten; whitespace
beneater authored
35
652c889 @praveenRamalingam Added new exercise Understanding moving the decimal
praveenRamalingam authored
36 <div class="hints">
c95dba6 @praveenRamalingam Removed the use of word-problems.
praveenRamalingam authored
37 <div class="graphie">
38 init({
39 range: [ [ -1, 11 ], [ -1, 3 ] ],
40 scale: [30, 45]
41 });
bf6a2d8 @beneater Make circle round; 10->ten; whitespace
beneater authored
42
c95dba6 @praveenRamalingam Removed the use of word-problems.
praveenRamalingam authored
43 var digitsA = KhanUtil.digits( A );
bf6a2d8 @beneater Make circle round; 10->ten; whitespace
beneater authored
44
c95dba6 @praveenRamalingam Removed the use of word-problems.
praveenRamalingam authored
45 //Pad zeroes if need be for the decimal point
982224f @praveenRamalingam Copied smenks13 changes and removed an unnecessary comment.
praveenRamalingam authored
46 while ( digitsA.length &lt; A_DECIMAL + 1) {
c95dba6 @praveenRamalingam Removed the use of word-problems.
praveenRamalingam authored
47 digitsA.push( 0 );
48 }
bf6a2d8 @beneater Make circle round; 10->ten; whitespace
beneater authored
49
c95dba6 @praveenRamalingam Removed the use of word-problems.
praveenRamalingam authored
50 var digitsB = digitsA.slice();
bf6a2d8 @beneater Make circle round; 10->ten; whitespace
beneater authored
51
c95dba6 @praveenRamalingam Removed the use of word-problems.
praveenRamalingam authored
52 //For the leading zero 0.# only occurs with division
982224f @praveenRamalingam Copied smenks13 changes and removed an unnecessary comment.
praveenRamalingam authored
53 if ( digitsA.length &lt; B_DECIMAL + 1) {
c95dba6 @praveenRamalingam Removed the use of word-problems.
praveenRamalingam authored
54 digitsA.push( ' ' );
55 digitsB.push( 0 );
56 }
bf6a2d8 @beneater Make circle round; 10->ten; whitespace
beneater authored
57
c95dba6 @praveenRamalingam Removed the use of word-problems.
praveenRamalingam authored
58 drawDigits( digitsA.reverse(), 0, 1);
59 drawDigits( digitsB.reverse(), 0, 0);
bf6a2d8 @beneater Make circle round; 10->ten; whitespace
beneater authored
60
982224f @praveenRamalingam Copied smenks13 changes and removed an unnecessary comment.
praveenRamalingam authored
61 for ( var i = 0; i &lt; POW_DIFF; i++) {
c95dba6 @praveenRamalingam Removed the use of word-problems.
praveenRamalingam authored
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" );
bf6a2d8 @beneater Make circle round; 10->ten; whitespace
beneater authored
65
c95dba6 @praveenRamalingam Removed the use of word-problems.
praveenRamalingam authored
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 }
bf6a2d8 @beneater Make circle round; 10->ten; whitespace
beneater authored
76
c95dba6 @praveenRamalingam Removed the use of word-problems.
praveenRamalingam authored
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" });
bf6a2d8 @beneater Make circle round; 10->ten; whitespace
beneater authored
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
c95dba6 @praveenRamalingam Removed the use of word-problems.
praveenRamalingam authored
87 var labelstr = "\\text{The decimal point needs to be moved " + POW_DIFF + " time" + ( POW_DIFF !== 1 ? "s.}" : ".}");
88 label ([ digitsA.length + 0.5, 0.5 ], labelstr, "right", 1);
652c889 @praveenRamalingam Added new exercise Understanding moving the decimal
praveenRamalingam authored
89 </div>
bf6a2d8 @beneater Make circle round; 10->ten; whitespace
beneater authored
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
c95dba6 @praveenRamalingam Removed the use of word-problems.
praveenRamalingam authored
93 <div data-if="PM === 1 && POW_DIFF !== 1">
bf6a2d8 @beneater Make circle round; 10->ten; whitespace
beneater authored
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>
982224f @praveenRamalingam Copied smenks13 changes and removed an unnecessary comment.
praveenRamalingam authored
95 <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>
c95dba6 @praveenRamalingam Removed the use of word-problems.
praveenRamalingam authored
97 <div data-if="PM !== 1 && POW_DIFF !== 1">
bf6a2d8 @beneater Make circle round; 10->ten; whitespace
beneater authored
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>
982224f @praveenRamalingam Copied smenks13 changes and removed an unnecessary comment.
praveenRamalingam authored
99 <code>{<var>A_FLOAT.toFixed( A_DECIMAL )</var>} \div {<var>pow( 10, POW_DIFF )</var>} = {<var>B_FLOAT.toFixed( B_DECIMAL )</var>}</code></p>
652c889 @praveenRamalingam Added new exercise Understanding moving the decimal
praveenRamalingam authored
100 </div>
bf6a2d8 @beneater Make circle round; 10->ten; whitespace
beneater authored
101
c95dba6 @praveenRamalingam Removed the use of word-problems.
praveenRamalingam authored
102 <div>
bf6a2d8 @beneater Make circle round; 10->ten; whitespace
beneater authored
103 <p>You need to <var>OPERATOR</var> by ten <code><var>POW_DIFF</var></code> time<span data-if="POW_DIFF !== 1">s</span>.</p>
104 </div>
105
652c889 @praveenRamalingam Added new exercise Understanding moving the decimal
praveenRamalingam authored
106 </div>
107 </div>
108 </body>
bf6a2d8 @beneater Make circle round; 10->ten; whitespace
beneater authored
109 </html>
Something went wrong with that request. Please try again.