Course:CPSC532:StaRAI:2017:As1:Q3

From UBC Wiki



Multi digit binary subtraction: Start from the rightmost digit. If Y0 is 0 then Z0 is the same as X0. If both Y0 and X0 are 1, Z0 is 0. If Y0 is 1 while X0 is 0, then need to borrow 1 from the left digit (called borrowed out). For the rest of the digits, the procedure repeats with the following exceptions: If the right digit borrowed from the current Yi, then add 1 to Yi (called borrowed in). If Yi becomes 2, then Zi becomes Xi and 1 is borrowed in to the next digit. Errors to make:Don't know single digit subtraction, don't know how to borrow in or borrow out, don't know whether to borrow 1 or 0. For part e, Only Xi, Yi and Zi should be replicated, other variables should be shared


Multi digit binary subtraction: canSub shows if the student knows how to sub or not, and canCarry shows whether student know when and how to carry.