News for hackers. Stuff that matters.
Re:Data structures and algorithms interview questions and th... by bogomipz on Saturday October 14, 2017 @10:53PM (#15475631)
>"or unroll the (fixed iteration) shift-and-add loop"

Can you elaborate on this? I understand the shifting but didn't understand the "loop unrolling fixed iteration part"

Re:Data structures and algorithms interview questions and th... by userbinator on Saturday October 14, 2017 @11:48PM (#15475781)
The shift-and-add algorithm for multiplication is usually implemented as a loop that iterates for the number of bits of the operand, so e.g. for an 8-bit x 8-bit multiplication, the loop runs 8 times. (An "early out" algorithm when one of the operands becomes 0 is also common, but let's not complicate things here.) It's trivial to unroll this loop into the 8 individual shift-and-add steps.