This repository has been archived by the owner on May 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 863
/
adding_decimals_2.html
57 lines (56 loc) · 2.44 KB
/
adding_decimals_2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!DOCTYPE html>
<html data-require="math graphie graphie-helpers-arithmetic">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Adding decimals 2</title>
<script src="../khan-exercise.js"></script>
</head>
<body>
<div class="exercise">
<div class="vars">
<var id="A">randRange( 100, 999 )</var>
<var id="B">randRange( 100, 999 )</var>
<var id="A_DECIMAL">randRange( 1, 3 )</var>
<var id="B_DECIMAL" data-ensure="B_DECIMAL!==A_DECIMAL">randRange( 1, 3 )</var>
<var id="NEW_A">A * ( B_DECIMAL > A_DECIMAL ? pow( 10, B_DECIMAL - A_DECIMAL ) : 1)</var>
<var id="NEW_B">B * ( A_DECIMAL > B_DECIMAL ? pow( 10, A_DECIMAL - B_DECIMAL ) : 1)</var>
<var id="A_DIGITS">
(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;
})()</var>
<var id="B_DIGITS">
(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;
})()</var>
<var id="DUMMY">[]</var>
</div>
<div class="problems">
<div>
<p class="question"><code>\Huge{<var>roundTo( A_DECIMAL, A * pow( 10, -A_DECIMAL ) ).toFixed( A_DECIMAL )</var> + <var>roundTo( B_DECIMAL, B * pow( 10, -B_DECIMAL ) ).toFixed( B_DECIMAL )</var> = {?}}</code></p>
<div class="solution" data-type="decimal"><var>A / pow( 10, A_DECIMAL ) + B / pow( 10, B_DECIMAL )</var></div>
<div class="graphie" id="numbers">
graph.adder = new Adder( NEW_A, NEW_B, A_DIGITS, B_DIGITS );
DUMMY = Array( graph.adder.getNumHints() );
</div>
</div>
</div>
<div class="hints">
<div class="graphie" data-update="numbers">
graph.adder.show();
graph.adder.showDecimals( A_DECIMAL, B_DECIMAL );
</div>
<div class="graphie" data-update="numbers" data-each="DUMMY as dummy">
graph.adder.showHint();
</div>
</div>
</div>
</body>
</html>