// Numbas version: exam_results_page_options {"name": "Use the decimal type when dealing with big numbers", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Use the decimal type when dealing with big numbers", "tags": [], "metadata": {"description": "
Because JavaScript numbers lose precision as they get bigger, you get some unexpected results.
\nSee the variable \"two\" - the difference should be 2, but because the JavaScript representation of each of the two numbers is the same, it thinks the difference is 0.
\nUsing the decimal data type, there's no loss of precision, so the correct value is produced.
", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "", "advice": "", "rulesets": {}, "extensions": [], "variables": {"two": {"name": "two", "group": "Ungrouped variables", "definition": "10^17-(10^17-2)", "description": "Compute $10^{17} - (10^{17}-2)$ using the standard number type. They lose precision at that order of magnitude, so the 2 is lost.
", "templateType": "anything"}, "dec_two": {"name": "dec_two", "group": "Ungrouped variables", "definition": "dec(10)^17-(dec(10)^17-2)", "description": "Compute $10^{17} - (10^{17}-2)$ using the decimal number type. It is much more precise, so produces the correct value, 2.
", "templateType": "anything"}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["two", "dec_two"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}]}]}], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}]}