5.9 · exercise
double, double, double
Multiplying by a power of two never needs a multiply: shifting left by one bit doubles a value, and doing it three times multiplies by eight.
Compute 8 * (a + b) using shifts instead of mul. The starter adds up nothing yet; put the sum in the total register and scale it with lsl.
what is checked
- the scaled sum is printed on its own line
- the program exits cleanly
- the scaling is done with a left shift, and
mulstays out of the program
Specification
args
stdoutprints the expected output
exitexits with the expected code
sourceuses
lslsourcecomputes the result (does not hardcode it)
sourcecomputes the result (does not hardcode it)
Checked by running your program against expected behavior, never by matching a stored solution.
loading editor...