// Numbas version: exam_results_page_options {"name": "Rounding numbers to a given number of decimal places", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Rounding numbers to a given number of decimal places", "type": "question", "tags": ["rounding", "taxonomy"], "variablesTest": {"condition": "", "maxRuns": "100"}, "variables": {"c1": {"templateType": "anything", "name": "c1", "description": "

Random number with 5 decimal places.

", "definition": "n_from_digits(cdig)*10^(-5) + random(1..5)", "group": "Ungrouped variables"}, "cdig": {"templateType": "anything", "name": "cdig", "description": "", "definition": "repeat(random(1..9), 5)", "group": "Ungrouped variables"}, "dp": {"templateType": "anything", "name": "dp", "description": "

Number of decimal places to round.

", "definition": "random(3..4)", "group": "Ungrouped variables"}}, "extensions": [], "functions": {"n_from_digits": {"parameters": [["digits", "list"]], "type": "number", "language": "jme", "definition": "if(\n len(digits)=0,\n 0,\n digits[0]+10*n_from_digits(digits[1..len(digits)])\n)"}}, "statement": "

We can approximate numbers by rounding.

\n

Round $\\var{c1}$ to a given number of decimal places.

", "variable_groups": [], "parts": [{"scripts": {}, "variableReplacements": [], "marks": 0, "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "gaps": [{"correctAnswerFraction": false, "scripts": {}, "type": "numberentry", "variableReplacementStrategy": "originalfirst", "allowFractions": false, "maxValue": "precround(c1, 1)", "showFeedbackIcon": true, "minValue": "precround(c1, 1)", "correctAnswerStyle": "plain", "mustBeReducedPC": 0, "mustBeReduced": false, "notationStyles": ["plain", "en", "si-en"], "variableReplacements": [], "marks": 1, "showCorrectAnswer": true}, {"correctAnswerFraction": false, "scripts": {}, "type": "numberentry", "variableReplacementStrategy": "originalfirst", "allowFractions": false, "maxValue": "precround(c1, 2)", "showFeedbackIcon": true, "minValue": "precround(c1, 2)", "correctAnswerStyle": "plain", "mustBeReducedPC": 0, "mustBeReduced": false, "notationStyles": ["plain", "en", "si-en"], "variableReplacements": [], "marks": 1, "showCorrectAnswer": true}, {"correctAnswerFraction": false, "scripts": {}, "type": "numberentry", "variableReplacementStrategy": "originalfirst", "allowFractions": false, "maxValue": "precround(c1, dp)", "showFeedbackIcon": true, "minValue": "precround(c1, dp)", "correctAnswerStyle": "plain", "mustBeReducedPC": 0, "mustBeReduced": false, "notationStyles": ["plain", "en", "si-en"], "variableReplacements": [], "marks": 1, "showCorrectAnswer": true}], "showCorrectAnswer": true, "prompt": "

i)   $\\var{c1}$ rounded to 1 decimal place is:  [[0]]

\n

ii)   $\\var{c1}$ rounded to 2 decimal places is:  [[1]]

\n

iii)   $\\var{c1}$ rounded to {dp} decimal places is:  [[2]]

\n

", "type": "gapfill"}], "ungrouped_variables": ["dp", "cdig", "c1"], "rulesets": {}, "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "

Round numbers to a given number of decimal places.

"}, "preamble": {"css": "", "js": ""}, "advice": "

The first thing to do when we are rounding numbers is to identify the last digit we are keeping.

\n

When you're asked to round your answer to a number of decimal places, you need to decide whether to keep the last digit same (rounding down) or increase it by 1 (rounding up). If the following digit is less than 5 we round down and we round up when the next digit is 5 or more.

\n

To write it down in steps:

\n
    \n
      \n
        \n
          \n
        1. Identify the last digit we need to keep.
        2. \n
        3. Look at the following digit.
        4. \n
        5. If it's 5 or more, increase the previous digit by one.
        6. \n
        7. If it's 4 or less, keep the previous digit the same.
        8. \n
        9. Fill any spaces to the right of the digit with zeros if needed.
        10. \n
        \n
      \n
    \n
\n

It is important to keep in mind that if the digit we are increasing is 9, it becomes zero and we increase the previous digit instead. If this digit is 9 as well, we move along to the left side until we find a digit less than 9.

\n
\n

To round a number to a given number $n$ of decimal places, we look at the $n$th digit after the decimal point.

\n

We have $\\var{c1}$.

\n

i)

\n

We look at the first digit after the decimal point. This is $\\var{cdig[4]}$ and the following digit is $\\var{cdig[3]}$ so we round updown to get $\\var{precround(c1, 1)}$.

\n

ii)

\n

The second digit after the decimal point is $\\var{cdig[3]}$. It is followed by $\\var{cdig[2]}$ so we round updown to get $\\var{precround(c1, 2)}$.

\n

iii)

\n

The 3rd decimal place is $\\var{cdig[2]}$, followed by $\\var{cdig[1]}$. We get $\\var{precround(c1, 3)}$. The 4th decimal place is $\\var{cdig[1]}$, followed by $\\var{cdig[0]}$. We get $\\var{precround(c1, 4)}$.

\n

", "contributors": [{"name": "Stanislav Duris", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1590/"}]}]}], "contributors": [{"name": "Stanislav Duris", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1590/"}]}