Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 66 lines (62 sloc) 3.043 kb
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 58 59 60 61 62 63 64 65
<!DOCTYPE html>
<html data-require="math math-format graphie graphie-helpers word-problems">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Rounding whole numbers</title>
    <script data-main="../local-only/main.js" src="../local-only/require.js"></script>
</head>

<body>
<div class="exercise">
    <div class="problems">
        <div id="all-digits-random" data-weight="2">
            <div class="vars">
                <var id="DIGITS">shuffle( [1, 2, 3, 4, 5, 6, 7, 8, 9], 5 )</var>
                <var id="NUM">+DIGITS.join( "" )</var>
                <var id="PLACE">randFromArray([ -2, -3 ])</var>
                <var id="TPLACE">numberPlaceNames[-PLACE]</var>
                <var id="TPLACES">plural_form(numberPlaceNames[-PLACE - 1], 2)</var>
                <var id="ROUNDED">Math.round(roundTo( PLACE, NUM ))</var>
                <var id="KEYDIGIT">DIGITS[5 + PLACE]</var>
            </div>

            <p class="question">Round <code><var>commafy( NUM )</var></code> to the nearest <var>TPLACE</var>.</p>
            <div class="solution" data-forms="integer"><var>ROUNDED</var></div>
        </div>
        <div id="look-at-five" data-weight="1">
            <div class="vars">
                <var id="PLACE">randFromArray([ -2, -3 ])</var>
                <var id="DIGITS">
                    (function() {
                        var digits = shuffle( [1, 2, 3, 4, 6, 7, 8, 9], 5 );
                        digits[ 5 + PLACE ] = 5;
                        return digits;
                    })()
                </var>
                <var id="NUM">+DIGITS.join( "" )</var>
                <var id="TPLACE">numberPlaceNames[-PLACE]</var>
                <var id="TPLACES">plural_form(numberPlaceNames[-PLACE - 1], 2)</var>
                <var id="ROUNDED">roundTo( PLACE, NUM )</var>
                <var id="KEYDIGIT">5</var>
            </div>
            <p class="question">Round <code><var>commafy( NUM )</var></code> to the nearest <var>TPLACE</var>.</p>
            <div class="solution" data-forms="integer"><var>ROUNDED</var></div>
        </div>
    </div>

    <div class="hints">
        <p>
            Because we want to round to the <var>plural_form(TPLACE, 2)</var> place, we need to look at the digit in the <var>TPLACES</var> place.
        </p>
        <p>The digit in the <var>TPLACES</var> place is <code><var>KEYDIGIT</var></code>.</p>
        <p data-if="KEYDIGIT > 5">
            Because <code><var>KEYDIGIT</var></code> is more than <code>5</code>, we round up to <code><var>commafy(ROUNDED)</var></code>.
        </p>
        <p data-else-if="KEYDIGIT === 5">
            Because the <var>TPLACES</var> place digit is <code><var>KEYDIGIT</var></code>,
            we round up to <code><var>commafy(ROUNDED)</var></code>.
        </p>
        <p data-else="">
            Because <code><var>KEYDIGIT</var></code> is less than <code>5</code>, we round down to <code><var>commafy(ROUNDED)</var></code>.
        </p>
    </div>
</div>
</body>
</html>
Something went wrong with that request. Please try again.