// Numbas version: finer_feedback_settings {"name": "Simon's copy of Decimal to Binary", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "
\nrebelmaths
"}, "variablesTest": {"condition": "", "maxRuns": 100}, "tags": [], "name": "Simon's copy of Decimal to Binary", "advice": "There is a video on converting decimal to binary below:
\nhttps://www.youtube.com/watch?v=H4BstqvgBow
\n\nFirst list the powers of 2 $2^0=1,2^1=2,2^2=4,2^3=8,2^4=16,2^5=32...$
\n\n(a)
\nWe can note that $\\var{ans1}=(\\var{b2}\\times4)+(\\var{b3}\\times2)+(\\var{b4}\\times1)$,
\nSo, the answer is $\\var{b2}\\var{b3}\\var{b4}$.
\n\n
\n
An alternative method to convert from decimal to binary is to repeatedly divide by 2, noting the remainder at each stage. Writing these remainders in reverse order then gives the binary representation of the number.
\n$\\var{ans1}\\div 2 = \\var{floor(ans1/2)}$ rem $\\var{mod(ans1,2)}$
\n$\\var{floor(ans1/2)}\\div 2 = \\var{floor(floor(ans1/2)/2)}$ rem $\\var{mod(floor(ans1/2),2)}$
\n$\\var{floor(floor(ans1/2)/2)}\\div 2 = \\var{floor(floor(floor(ans1/2)/2)/2)}$ rem $\\var{mod(floor(floor(ans1/2)/2),2)}$
\n\nWriting these remainders in reverse order gives a final answer of $\\var{mod(floor(floor(ans1/2)/2),2)}\\var{mod(floor(ans1/2),2)}\\var{mod(ans1,2)}$
\n\n\n(b)
\n$\\var{ans2}=(\\var{b1}\\times16)+(\\var{b2}\\times8)+(\\var{b3}\\times4)+(\\var{b4}\\times2)+(\\var{b5}\\times1)$,
\nSo, the answer is $\\var{b1}\\var{b2}\\var{b3}\\var{b4}\\var{b5}$
\n\n\nAn alternative method to convert from decimal to binary is to repeatedly divide by 2, noting the remainder at each stage. Writing these remainders in reverse order then gives the binary representation of the number.
\n$\\var{ans2}\\div 2 = \\var{floor(ans2/2)}$ rem $\\var{mod(ans2,2)}$
\n$\\var{floor(ans2/2)}\\div 2 = \\var{floor(floor(ans2/2)/2)}$ rem $\\var{mod(floor(ans2/2),2)}$
\n$\\var{floor(floor(ans2/2)/2)}\\div 2 = \\var{floor(floor(floor(ans2/2)/2)/2)}$ rem $\\var{mod(floor(floor(ans2/2)/2),2)}$
\n$\\var{floor(floor(floor(ans2/2)/2)/2)}\\div 2 = \\var{floor(floor(floor(floor(ans2/2)/2)/2)/2)}$ rem $\\var{mod(floor(floor(floor(ans2/2)/2)/2),2)}$
\n$\\var{floor(floor(floor(floor(ans2/2)/2)/2)/2)}\\div 2 = \\var{floor(floor(floor(floor(floor(ans2/2)/2)/2)/2)/2)}$ rem $\\var{mod(floor(floor(floor(floor(ans2/2)/2)/2)/2),2)}$
\n\nWriting these remainders in reverse order gives a final answer of $\\var{mod(floor(floor(floor(floor(ans2/2)/2)/2)/2),2)}\\var{mod(floor(floor(floor(ans2/2)/2)/2),2)}\\var{mod(floor(floor(ans2/2)/2),2)}\\var{mod(floor(ans2/2),2)}\\var{mod(ans2,2)}$
\n\n\n(c)
\n$\\var{ans3}=(\\var{b1}\\times128)+(\\var{b2}\\times64)+(\\var{b3}\\times32)+(\\var{b4}\\times16)+(\\var{b5}\\times8)+(\\var{b6}\\times4)+(\\var{b7}\\times2)+(\\var{b8}\\times1)$
\nSo, the answer is $\\var{b1}\\var{b2}\\var{b3}\\var{b4}\\var{b5}\\var{b6}\\var{b7}\\var{b8}$.
", "variables": {"b7": {"templateType": "randrange", "name": "b7", "description": "", "group": "Ungrouped variables", "definition": "random(0..1#1)"}, "b1": {"templateType": "anything", "name": "b1", "description": "", "group": "Ungrouped variables", "definition": "1"}, "b8": {"templateType": "randrange", "name": "b8", "description": "", "group": "Ungrouped variables", "definition": "random(0..1#1)"}, "a": {"templateType": "randrange", "name": "a", "description": "", "group": "Ungrouped variables", "definition": "random(1..20#1)"}, "b2": {"templateType": "anything", "name": "b2", "description": "", "group": "Ungrouped variables", "definition": "1"}, "ans3": {"templateType": "anything", "name": "ans3", "description": "", "group": "Ungrouped variables", "definition": "{b8}*1+{b7}*2+{b6}*4+{b5}*8+{b4}*16+{b3}*32+{b2}*64+{b1}*128"}, "b6": {"templateType": "randrange", "name": "b6", "description": "", "group": "Ungrouped variables", "definition": "random(0..1#1)"}, "ans1": {"templateType": "anything", "name": "ans1", "description": "", "group": "Ungrouped variables", "definition": "{b4}+{b3}*2+{b2}*4"}, "b5": {"templateType": "randrange", "name": "b5", "description": "", "group": "Ungrouped variables", "definition": "random(0..1#1)"}, "ans2": {"templateType": "anything", "name": "ans2", "description": "", "group": "Ungrouped variables", "definition": "{b5}*1+{b4}*2+{b3}*4+{b2}*8+{b1}*16"}, "b4": {"templateType": "randrange", "name": "b4", "description": "", "group": "Ungrouped variables", "definition": "random(0..1#1)"}, "b3": {"templateType": "randrange", "name": "b3", "description": "", "group": "Ungrouped variables", "definition": "random(0..1#1)"}}, "preamble": {"css": "", "js": ""}, "ungrouped_variables": ["a", "b1", "b2", "b3", "b4", "b5", "b7", "b6", "ans1", "ans2", "ans3", "b8"], "parts": [{"variableReplacements": [], "customMarkingAlgorithm": "", "unitTests": [], "gaps": [{"variableReplacements": [], "customMarkingAlgorithm": "", "unitTests": [], "displayAnswer": "{b2}{b3}{b4}", "matchMode": "exact", "answer": "{b2}{b3}{b4}", "type": "patternmatch", "scripts": {}, "marks": 1, "extendBaseMarkingAlgorithm": true, "showFeedbackIcon": true, "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true}], "type": "gapfill", "prompt": "Convert the number $\\var{ans1}$ to binary.
\n[[0]]
", "marks": 0, "extendBaseMarkingAlgorithm": true, "sortAnswers": false, "showFeedbackIcon": true, "scripts": {}, "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true}, {"variableReplacements": [], "customMarkingAlgorithm": "", "unitTests": [], "gaps": [{"variableReplacements": [], "customMarkingAlgorithm": "", "unitTests": [], "displayAnswer": "{b1}{b2}{b3}{b4}{b5}", "matchMode": "exact", "answer": "{b1}{b2}{b3}{b4}{b5}", "type": "patternmatch", "scripts": {}, "marks": 1, "extendBaseMarkingAlgorithm": true, "showFeedbackIcon": true, "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true}], "type": "gapfill", "prompt": "Convert the number $\\var{ans2}$ to binary.
\n[[0]]
\n", "marks": 0, "extendBaseMarkingAlgorithm": true, "sortAnswers": false, "showFeedbackIcon": true, "scripts": {}, "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true}, {"variableReplacements": [], "customMarkingAlgorithm": "", "unitTests": [], "gaps": [{"variableReplacements": [], "customMarkingAlgorithm": "", "unitTests": [], "displayAnswer": "{b1}{b2}{b3}{b4}{b5}{b6}{b7}{b8}", "matchMode": "exact", "answer": "{b1}{b2}{b3}{b4}{b5}{b6}{b7}{b8}", "type": "patternmatch", "scripts": {}, "marks": 1, "extendBaseMarkingAlgorithm": true, "showFeedbackIcon": true, "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true}], "type": "gapfill", "prompt": "Convert the number $\\var{ans3}$ to binary.
\n[[0]]
", "marks": 0, "extendBaseMarkingAlgorithm": true, "sortAnswers": false, "showFeedbackIcon": true, "scripts": {}, "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true}], "rulesets": {}, "statement": "Answer the following questions putting a 1 or 0 in each box.
", "extensions": [], "variable_groups": [], "functions": {}, "type": "question", "contributors": [{"name": "Julie Crowley", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/113/"}, {"name": "Simon Thomas", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3148/"}], "resources": []}]}], "contributors": [{"name": "Julie Crowley", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/113/"}, {"name": "Simon Thomas", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3148/"}]}