// Numbas version: exam_results_page_options {"name": "Decimals: Subtraction", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false}, "question_groups": [{"questions": [{"functions": {}, "metadata": {"licence": "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International", "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.

"}, "variables": {"newtopten": {"definition": "if(unitdiff>=0,top[1],top[1]-1)", "templateType": "anything", "group": "c", "description": "", "name": "newtopten"}, "tendiff": {"definition": "if(unitdiff>=0,top[1]-bot[1],top[1]-1-bot[1])", "templateType": "anything", "group": "c", "description": "", "name": "tendiff"}, "botnum": {"definition": "bot[0]/1000+bot[1]/100+bot[2]/10", "templateType": "anything", "group": "c", "description": "", "name": "botnum"}, "newtophun": {"definition": "if(tendiff>=0,top[2],top[2]-1)", "templateType": "anything", "group": "c", "description": "", "name": "newtophun"}, "bot": {"definition": "random(\nif(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\"),\nif(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", "templateType": "anything", "group": "c", "description": "

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

", "name": "bot"}, "hundiff": {"definition": "if(tendiff>=0,top[2]-bot[2],top[2]-1-bot[2])", "templateType": "anything", "group": "c", "description": "", "name": "hundiff"}, "unitdiff": {"definition": "top[0]-bot[0]", "templateType": "anything", "group": "c", "description": "", "name": "unitdiff"}, "top": {"definition": "random([random(0..9),random(1..8),random(2..9)],[0,random(1..9),random(2..9)])", "templateType": "anything", "group": "c", "description": "", "name": "top"}, "ans": {"definition": "topnum-botnum", "templateType": "anything", "group": "c", "description": "", "name": "ans"}, "ansten": {"definition": "mod(floor(ans*100),10)", "templateType": "anything", "group": "c", "description": "", "name": "ansten"}, "anshun": {"definition": "mod(floor(ans*10),10)", "templateType": "anything", "group": "c", "description": "", "name": "anshun"}, "topnum": {"definition": "top[0]/1000+top[1]/100+top[2]/10", "templateType": "anything", "group": "c", "description": "", "name": "topnum"}, "ansunit": {"definition": "mod(ans*1000,10)", "templateType": "anything", "group": "c", "description": "", "name": "ansunit"}}, "contributors": [{"name": "Ben Brawn", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/605/"}], "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.

", "variablesTest": {"maxRuns": 100, "condition": ""}, "variable_groups": [{"name": "c", "variables": ["top", "bot", "topnum", "botnum", "ans", "unitdiff", "tendiff", "hundiff", "ansunit", "ansten", "anshun", "newtopten", "newtophun"]}], "ungrouped_variables": [], "rulesets": {}, "extensions": [], "name": "Decimals: Subtraction", "parts": [{"variableReplacements": [], "steps": [{"customMarkingAlgorithm": "", "variableReplacements": [], "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]}\$ \$\\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

", "unitTests": [], "marks": 0, "variableReplacementStrategy": "originalfirst", "extendBaseMarkingAlgorithm": true, "showCorrectAnswer": true, "scripts": {}, "type": "information", "showFeedbackIcon": true}], "customMarkingAlgorithm": "", "prompt": "

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

", "stepsPenalty": "1", "gaps": [{"minValue": "ans", "marks": 1, "variableReplacements": [], "showCorrectAnswer": true, "correctAnswerStyle": "plain", "unitTests": [], "mustBeReducedPC": 0, "correctAnswerFraction": false, "maxValue": "ans", "mustBeReduced": false, "showFeedbackIcon": true, "customMarkingAlgorithm": "", "allowFractions": false, "notationStyles": ["plain", "en", "si-en"], "variableReplacementStrategy": "originalfirst", "extendBaseMarkingAlgorithm": true, "scripts": {}, "type": "numberentry"}], "marks": 0, "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "sortAnswers": false, "showFeedbackIcon": true, "unitTests": [], "extendBaseMarkingAlgorithm": true, "scripts": {}, "type": "gapfill"}], "preamble": {"css": "", "js": ""}, "tags": [], "type": "question", "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.

"}], "pickingStrategy": "all-ordered"}], "contributors": [{"name": "Ben Brawn", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/605/"}]}