// Numbas version: exam_results_page_options {"name": "Decimals: Subtraction", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Decimals: Subtraction", "tags": [], "metadata": {"description": "

Subtracting a decimal with 3 decimal places from a decimal with 2 or 3 decimal places. borrowing is necessary. This was modified from a subtraction question using integers with each number divided by 1000 so the variables have names referring to ones, tens, hundreds etc.

", "licence": "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International"}, "statement": "

Write the following question down on paper and evaluate it without using a calculator.

\n

If you are unsure of how to do a question, click on Show steps to see the full working. Then, once you understand how to do the question, click on Try another question like this one to start again.

", "advice": "

Write the following question down on paper and evaluate it without using a calculator.

\n

If you are unsure of how to do a question, click on Show steps to see the full working. Then, once you understand how to do the question, click on Try another question like this one to start again.

", "rulesets": {}, "extensions": [], "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"tendiff": {"name": "tendiff", "group": "c", "definition": "if(unitdiff>=0,top[1]-bot[1],top[1]-1-bot[1])", "description": "", "templateType": "anything", "can_override": false}, "hundiff": {"name": "hundiff", "group": "c", "definition": "if(tendiff>=0,top[2]-bot[2],top[2]-1-bot[2])", "description": "", "templateType": "anything", "can_override": false}, "newtopten": {"name": "newtopten", "group": "c", "definition": "if(unitdiff>=0,top[1],top[1]-1)", "description": "", "templateType": "anything", "can_override": false}, "ans": {"name": "ans", "group": "c", "definition": "topnum-botnum", "description": "", "templateType": "anything", "can_override": false}, "newtophun": {"name": "newtophun", "group": "c", "definition": "if(tendiff>=0,top[2],top[2]-1)", "description": "", "templateType": "anything", "can_override": false}, "anshun": {"name": "anshun", "group": "c", "definition": "mod(floor(ans*10),10)", "description": "", "templateType": "anything", "can_override": false}, "topnum": {"name": "topnum", "group": "c", "definition": "top[0]/1000+top[1]/100+top[2]/10", "description": "", "templateType": "anything", "can_override": false}, "ansunit": {"name": "ansunit", "group": "c", "definition": "mod(ans*1000,10)", "description": "", "templateType": "anything", "can_override": false}, "unitdiff": {"name": "unitdiff", "group": "c", "definition": "top[0]-bot[0]", "description": "", "templateType": "anything", "can_override": false}, "bot": {"name": "bot", "group": "c", "definition": "if(top[0]<>0, \n random(\n [0, random(top[1]+1..9), random(1..top[2]-1)],\n [random(top[0]+1..9), random(0..9), random(1..top[2]-1)]), \n [random(1..9), random(2..9), 1])\n\n//original \n//random(\n//if(top[0]<9,[random(top[0]+1..9), random(top[1]..9), random(1..top[2]-1)],if(top[1]<9,[random(top[0]..9), random(top[1]+1..9), random(1..top[2]-1)]),\"error\"),\n//if(top[1]<9,[random(0..top[0]), random(top[1]+1..9), random(1..top[2]-1)],if(top[1]=9,[random(top[0]..9), random(0..9), random(1..top[2]-1)]),\"error\")\n//)\n\n", "description": "

This should force some borrowing and paying back, and that the final answer is positive.

", "templateType": "anything", "can_override": false}, "top": {"name": "top", "group": "c", "definition": "random([random(1..8),random(1..8),random(2..9)],[0,random(1..9),random(2..9)])", "description": "

the digits of a 2 or 3 decimal place number

", "templateType": "anything", "can_override": false}, "botnum": {"name": "botnum", "group": "c", "definition": "bot[0]/1000+bot[1]/100+bot[2]/10", "description": "", "templateType": "anything", "can_override": false}, "ansten": {"name": "ansten", "group": "c", "definition": "mod(floor(ans*100),10)", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": "100"}, "ungrouped_variables": [], "variable_groups": [{"name": "c", "variables": ["top", "bot", "topnum", "botnum", "ans", "unitdiff", "tendiff", "hundiff", "ansunit", "ansten", "anshun", "newtopten", "newtophun"]}], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "gapfill", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

$\\var{topnum}-\\var{botnum} = $ [[0]]

", "stepsPenalty": "1", "steps": [{"type": "information", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Generally we set up $\\var{topnum}-\\var{botnum}$ with the decimal points lined up vertically so that the columns with the same place value are also lined up vertically. We also pad out the decimals with zeros:

\n

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$0$.$\\var{top[2]}$$\\var{top[1]}$$\\color{red}{\\var{top[0]}}$ $\\var{top[0]}$$-$
$0$.$\\var{bot[2]}$$\\var{bot[1]}$$\\color{red}{\\var{bot[0]}}$ $\\var{bot[0]}$
.$\\phantom{0}$
\n

\n

Now we try to subtract the digits in the column to the far right (in this case, the thousandths column).

\n

Since this is $\\var{ansunit}$ we write $\\var{ansunit}$ under the line in this column.

\n

Since we can't take $\\var{bot[0]}$ away from $\\var{top[0]}$ (without using negative numbers) we borrow from the next column to the left (in this case, the hundredths column). This means we cross out the $\\var{top[1]}$ in the hundredths column and replace it with a $\\var{top[1]-1}$, and the $\\var{top[0]}$ becomes a $\\var{10+top[0]}$. Now we can do $\\var{10+top[0]}-\\var{bot[0]}$, and write the result, $\\var{ansunit}$, under the line in the thousandths column. 

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$\\overset{\\phantom{1}}{0}$.$\\overset{\\phantom{1}}{\\var{top[2]}}$$\\overset{\\color{red}{\\var{newtopten}}}{\\var{top[1]}\\mkern-7.5mu\\color{red}/}$ $\\overset{\\phantom{1}}{\\var{top[1]}}$$\\color{red}{^1}\\overset{\\phantom{1}}{\\color{green}{\\var{top[0]}}}$ $\\overset{\\phantom{1}}{\\color{green}{\\var{top[0]}}}$$-$
$0$.$\\var{bot[2]}$$\\var{bot[1]}$$\\color{green}{\\var{bot[0]}}$
.$\\color{red}{\\var{ansunit}}$
\n

\n

Now we try to subtract the digits in the hundredths column.

\n

Since this is $\\var{ansten}$ we write $\\var{ansten}$ under the line in this column.

\n

Since we can't take $\\var{bot[1]}$ away from $\\var{newtopten}$ (without using negative numbers) we borrow from the next column to the left (in this case, the tenths column). This means we cross out the $\\var{top[2]}$ in the tenths column and replace it with a $\\var{top[2]-1}$, and the $\\var{newtopten}$ in the hundredths column becomes a $\\var{10+newtopten}$. Now we can do $\\var{10+newtopten}-\\var{bot[1]}$, and write the result, $\\var{ansten}$, under the line in the hundredths. 

\n

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$\\overset{\\phantom{1}}{0}$.\n

$\\overset{\\color{red}{\\var{newtophun}}}{\\var{top[2]}\\mkern-7.5mu\\color{red}{/}}$ $\\overset{\\phantom{1}}{\\var{top[2]}}$

\n
\n

$\\overset{\\color{red}{1}\\color{green}{\\var{newtopten}}}{\\var{top[1]}\\mkern-7.5mu/}$ $\\overset{\\color{green}{\\var{newtopten}}}{\\var{top[1]}\\mkern-7.5mu/}$ $\\color{red}{^1}\\overset{\\phantom{1}}{\\color{green}{\\var{top[1]}}}$ $\\overset{\\phantom{1}}{\\color{green}{\\var{top[1]}}}$

\n
${^1}\\overset{\\phantom{1}}{\\var{top[0]}}$ $\\overset{\\phantom{1}}{\\var{top[0]}}$$-$
$0$.$\\var{bot[2]}$$\\color{green}{\\var{bot[1]}}$$\\var{bot[0]}$
.$\\color{red}{\\var{ansten}}$$\\var{ansunit}$
\n

\n

Now we try to subtract the digits in the tenths column and then subtract the digits in the ones column.

\n

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$\\overset{\\phantom{1}}{\\color{green}{0}}$.\n

$\\overset{\\color{green}{\\var{newtophun}}}{\\var{top[2]}\\mkern-7.5mu/}$ $\\overset{\\phantom{1}}{\\color{green}{\\var{top[2]}}}$

\n
\n

$\\overset{{1}\\var{newtopten}}{\\var{top[1]}\\mkern-7.5mu/}$ $\\overset{\\var{newtopten}}{\\var{top[1]}\\mkern-7.5mu/}$ ${^1}\\overset{\\phantom{1}}{\\var{top[1]}}$ $\\overset{\\phantom{1}}{\\var{top[1]}}$

\n
${^1}\\overset{\\phantom{1}}{\\var{top[0]}}$ $\\overset{\\phantom{1}}{\\var{top[0]}}$$-$
$\\color{green}0$.$\\color{green}{\\var{bot[2]}}$$\\var{bot[1]}$$\\var{bot[0]}$
$\\color{red}0$.$\\color{red}{\\var{anshun}}$$\\var{ansten}$$\\var{ansunit}$
\n

\n

\n

The answer is therefore $\\var{ans}$.

"}], "gaps": [{"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": "ans", "maxValue": "ans", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "contributors": [{"name": "Ben Brawn", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/605/"}]}]}], "contributors": [{"name": "Ben Brawn", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/605/"}]}