// Numbas version: finer_feedback_settings {"name": "Round a number to \\(n\\) decimal places", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Round a number to \\(n\\) decimal places", "tags": [], "metadata": {"description": "
Round a number to $n$ decimal places. Part of HELM Book 1.1
", "licence": "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International"}, "statement": "\nRound $\\var{n}$ to $\\var{d}$ decimal places:
To round to $\\var{d}$ decimal places we look at the $\\var{d+1}$ $^{nd}$ $^{rd}$ $^{th}$ digit after the decimal place in $\\var{n}$.
\nThis is $\\var{trunc(abs((n-trunc(n,d))),d+1)*10^(d+1)}$.
\n$\\var{trunc(abs((n-trunc(n,d))),d+1)*10^(d+1)}$ $< 5$ $>=5$ so we round down up to get $\\var{precround(n,d)}$
\n", "rulesets": {}, "extensions": [], "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"d": {"name": "d", "group": "Ungrouped variables", "definition": "random(1..3)", "description": "", "templateType": "anything", "can_override": false}, "n": {"name": "n", "group": "Ungrouped variables", "definition": "precround(random(-50..50 #0.00000001),random(4..7))", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["d", "n"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "precround(n,d)", "maxValue": "precround(n,d)", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "type": "question", "contributors": [{"name": "Don Shearman", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/680/"}, {"name": "Merryn Horrocks", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/4052/"}], "resources": []}]}], "contributors": [{"name": "Don Shearman", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/680/"}, {"name": "Merryn Horrocks", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/4052/"}]}