Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

58 lines (57 sloc) 2.928 kb
<!DOCTYPE html>
<html data-require="math">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Significant figures</title>
<script data-main="../local-only/main.js" src="../local-only/require.js"></script>
</head>
<body>
<div class="exercise">
<div class="vars">
<var id="LEADING"> Array( randRange( 0, 2 ) ).join( '0' ) </var>
<var id="RIGHTLEADING"> Array( randRange( 0, 2) ).join( '0' ) </var>
<var id="TRAILING"> Array( randRange( 0, 4 ) ).join( '0' ) </var>
<var id="IS_ZERO"> random() &gt; 0.5 </var>
<var id="HAS_DOT"> IS_ZERO ? true : random() &gt; 0.5 </var>
<var id="RIGHTSIDE"> randRange( 1, 9, randRange( 1, 6 ) ).join('') </var>
<var id="LEFTSIDE"> IS_ZERO ? '0' : randRange( 1, 9, randRange( 1, 4 ) ).join('') </var>
<var id="TOTAL"> HAS_DOT ?
LEADING + LEFTSIDE + '.' + RIGHTLEADING + RIGHTSIDE + TRAILING :
LEADING + LEFTSIDE + TRAILING </var>
<var id="SOLUTION"> IS_ZERO ?
RIGHTSIDE.length + TRAILING.length :
HAS_DOT ?
LEFTSIDE.length + RIGHTLEADING.length + RIGHTSIDE.length + TRAILING.length :
LEFTSIDE.length </var>
<var id="PROPER_LEADING"> IS_ZERO ? LEADING + LEFTSIDE + '.' + RIGHTLEADING : LEADING </var>
<var id="INBETWEEN"> IS_ZERO ? RIGHTSIDE : HAS_DOT ?
LEFTSIDE + '.' + RIGHTLEADING + RIGHTSIDE : LEFTSIDE </var>
</div>
<div class="problems">
<div>
<p class="question">How many significant figures does <code><var>TOTAL</var></code> have?</p>
<p class="solution" data-forms="integer"><var>SOLUTION</var></p>
</div>
</div>
<div class="hints">
<div>
<p>Identify the non-zero digits and any zeros between them. These are all significant.</p>
<p><code><var>PROPER_LEADING</var>\color{blue}{<var>INBETWEEN</var>}<var>TRAILING</var></code></p>
</div>
<div data-if="PROPER_LEADING.length > 0">
<p>Leading zeros are not significant.</p>
<p><code>\color{orange}{<var>PROPER_LEADING</var>}\color{blue}{<var>INBETWEEN</var>}<var>TRAILING</var></code></p>
</div>
<div data-if="TRAILING.length > 0 && HAS_DOT">
<p>Since there is a decimal, trailing zeros are significant.</p>
<p><code>\color{orange}{<var>PROPER_LEADING</var>}\color{blue}{<var>INBETWEEN</var><var>TRAILING</var>}</code></p>
</div>
<div data-if="TRAILING.length > 0 && !HAS_DOT">
<p>Since there is no decimal, trailing zeros are not significant.</p>
<p><code>\color{orange}{<var>PROPER_LEADING</var>}\color{blue}{<var>INBETWEEN</var>}\color{orange}{<var>TRAILING</var>}</code></p>
</div>
<p>Counting all the significant digits gives us <var>SOLUTION</var>.</p>
</div>
</div>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.